Published
Edited
Mar 11, 2018
1 star
Insert cell
Insert cell
{
var a = 1;
function b() {
a = 5;
console.log(a) // ?? a
function a() {}
}
b()
}
Insert cell
Insert cell
{
var num1 = 5,
num2 = 10,
result = num1+++num2;
console.log(num1)
console.log(num2)
console.log(result)
// ?? num1, num2, result
}
Insert cell
{
window.x = 5;
var o = {
x: 10,
doIt: function doIt(){
var x = 20;
setTimeout(function(){
console.log(this.x);
}, 10);
}
};
o.doIt();
}
Insert cell
{
var num1 = "10",
num2 = "9";
console.log(num1 < num2) // 字符串比较按字母顺序
console.log(+num1 < num2) // 字符串和数字比,将字符串转换为数字比较
console.log(num1 + num2) // 字符串相加
console.log(+num1 + num2) // 字符串相加
}
Insert cell
{
var message = "Hello world!";
console.log(message.substring(1, 4))
console.log(message.substr(1,4))
}
Insert cell
{
var o = {
x: 8,

valueOf: function(){
return this.x + 2;
},
toString: function(){
return this.x.toString();
}
},
result = o < "9";

console.log(o.toString());
console.log(result);
}
Insert cell
Insert cell
{
if (!("a" in window)) {
var a = 1;
}
console.log(a);
}
Insert cell
{
var a = 1,
b = function a(x) {
x && a(--x);
};
console.log(a);
}
Insert cell
{
function a(x) {
return x * 2;
}
var a;
console.log(a);
}
Insert cell
{
function a(){
return 1;
}
var a = 1;
console.log(a);
}
Insert cell
{
function b(x, y, a) {
arguments[2] = 10;
console.log(a); // 10 in all browser; if 'use strict', 3
}
b(1, 2, 3);
}
Insert cell
{
function a() {
console.log(this);// window
}
a.call(null);
}
Insert cell
Insert cell
{
var a = (function(){
return typeof arguments;
})();
console.log(a)
}
Insert cell
{
var f = function g(){ return 23; };
console.log(typeof g())
}
Insert cell
{
var a = (function(x){
delete x;
return x;
})(1);
console.log(a)
}
Insert cell
{
var y = 1, x = y = typeof x;
console.log(x);
}
Insert cell
{
var a = (function f(f){
return typeof f();
})(function(){ return 1; });
console.log(a)
}
Insert cell
{
var foo = {
bar: function() { return this.baz; },
baz: 1
};
var a = (function(){
return typeof arguments[0]();
})(foo.bar);
console.log(a)
}
Insert cell
{
var foo = {
bar: function(){ return this.baz; },
baz: 1
}
console.log(typeof (f = foo.bar)());
}
Insert cell
{
var f = (function f(){ return "1"; }, function g(){ return 2; })();
console.log(typeof f)
}
Insert cell
{
var x = 1;
if (function f(){}) {
x += typeof f;
}
console.log(x)
}
Insert cell
{
var x, y;
var x = [typeof x, typeof y][1];
console.log(typeof typeof x);
}
Insert cell
{
var a = (function(foo){
return typeof foo.bar;
})({ foo: { bar: 1 } });
console.log(a)
}
Insert cell
{
var a = (function f(){
function f(){ return 1; }
return f();
function f(){ return 2; }
})();
console.log(a)
}
Insert cell
{
function f(){ return f; }
console.log(new f() instanceof f)
}
Insert cell
{
with (function(x, undefined){}) { console.log(length);}
}
Insert cell
{
var a = (function f(){
var f
function f(){ return 1; }
return f();
// var f = '123'
function f(){ return 2; }
})();
console.log(a)
}
Insert cell
{
var a = (function f(){
var f = '1'
function f(){ return 1; }
return f();
// var f = '123'
function f(){ return 2; }
})();
console.log(a)
}
Insert cell
{
var a = (function f(){
//var f = 1
function f(){ return 1; }
return f();
var f = '123'
function f(){ return 2; }
})();
console.log(a)
}
Insert cell
Insert cell
{
function a() {
var a = 10;
if(a > 5) {
a = 7;
}
console.log(a);
}
a()
}
Insert cell
{
function a() {
if(true) {
var a = 5;
}
console.log(a);
}
a()
}
Insert cell
Insert cell
{
function first() {
window.a = 3;
}


function second() {
console.log(a);
}
first();
second();
}
Insert cell
{
var a = 5;
function b() {
var a = 7;
console.log(a);
}
b()
}
Insert cell
{
var a = 6;
function test() {
var a = 7;
function again() {
var a = 8;
console.log(a); // First
}
again();
console.log(a); // Second
}
test();
console.log(a); // Third
}
Insert cell
{
function getFunc() {
var a = 7;
return function(b) {
console.log(a+b);
}
}
var f = getFunc();
f(5);
}
Insert cell
Insert cell
{
console.log(typeof typeof(null))
}
Insert cell
{
console.log(100['toString']['length']);
console.log('asdf'['toString']['length']);
}
Insert cell
{
var a = (1,5 - 1) * 2;
console.log(a)
}
Insert cell
{
var x = 10;
var foo = {
x: 20,
bar: function () {
var x = 30;
return this.x;
}
};

console.log(
foo.bar(),
(foo.bar)(),
(foo.bar = foo.bar)(),
(foo.bar, foo.bar)()
);
}
Insert cell
{
function f(x, y) {
x = 10;
console.log(
arguments[0],
arguments[1]
);
}

f();
}
Insert cell
{
var
b = 10,
c = (
20,
function (x) { return x + 100},
function () { return arguments[0]}
);

var a = b + c
console.log(a)
console.log( ({x: 10}).x)
}
Insert cell
{
({
x: 10,
foo: function () {
function bar() {
console.log(x);
console.log(y);
console.log(this.x);
}
with (this) {
var x = 20;
var y = 30;
bar.call(this);
}
}
}).foo();
}
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more