2016-04-08

Lu Yuan

Everything is an expression

let x = 10;

let a = eval(`
  if (x === 10) {
    100;
  } else if (x > 10) {
    200;
  } else {
    300;
  }
`);

console.log(`a is ${a}`); // a is 100

Sorting algorithms in JavaScript

Chrome Supports createImageBitmap() in Chrome 50

Match - JavaScript library to test JSON with some nice features

ASCII art in JavaScript

About String Concatenation

// ECMA-262, section 15.5.4.6
function StringConcat() {
  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
    throw MakeTypeError("called_on_null_or_undefined",
                        ["String.prototype.concat"]);
  }
  var len = %_ArgumentsLength();
  var this_as_string = TO_STRING_INLINE(this);
  if (len === 1) {
    return this_as_string + %_Arguments(0);
  }
  var parts = new InternalArray(len + 1);
  parts[0] = this_as_string;
  for (var i = 0; i < len; i++) {
    var part = %_Arguments(i);
    parts[i + 1] = TO_STRING_INLINE(part);
  }
  return %StringBuilderConcat(parts, len + 1, "");
}
a = {
 nodeA: 'abc',
 nodeB: 'def'
}

// And b = a.concat('123')

b = {
  nodeA: a, /* {
             nodeA: 'abc',
             nodeB: 'def'
          } */
  nodeB: '123'
}      

2016-04-08

By luyuan

2016-04-08

You know it.

  • 1,097