var list = [1, 2, 3, 4, 5];
list.length = 3;
console.log(list); // => [1, 2, 3]
var name, realCat, evilCat;
function Cat(name) {
realCat = this ;
this .name = name;
return {name: 'churchill' };
}
evilCat = new Cat( 'barsik' );
console.log(evilCat.name); // => 'churchill'
console.log(realCat.name); // => 'barsik'
console.log(name); // => undefined
var name;
new function Cat() {
this .name = 'barsik' ;
( function () {
console.log( this .name); // => undefined
})();
}
( function (a) {
console.log(a); // => 'a'
arguments[0] = 'b' ;
console.log(a); // => 'b'
})( 'a' );
Source: https://habr.com/ru/post/115321/
All Articles