Just some Aha! moments in learning Javascript.
Just some Aha! moments in learning Javascript.
Object.create()
behaves the same as:
function object(o) {
function F() {}
F.prototype = o
return new F()
}
data property
, and the other is accessor property
.Object.defineProperty
, both data property
and accessor property
have these keys as descriptor:configurable
, enumerable
, value
, writable
,accessor property
has get
and set
1, formalized the __proto__
property.
2, Safe integers
Number.MAX_SAFE_INTEGER = 2^53
Number.MIN_SAFE_INTEGER = -2^53
Number.isSafeInteger(num)
3, New Math methods:
Math.acosh(x)
, Math.asinh(x)
, Math.atanh(x)
Math.cbrt(x)
The cubed root of x
Math.log1p(x)
: The natural logarithm of 1 + x
, Math.log2(x)
, Math.log10(x)
Math.trunc(x)
: Remove the fration from a float.
4, UTF-16 support:codePointAt()
method.
executor
in new Promise()
is executed immediately.will log the
var p = new Promise(function(resolve, reject) {
console.log('Yeah');
resolve(42);
})
Yeah
right after this declaration.Object.freeze()
and Object.seal()
seal: preventing new properties from being added to it and marking all existing properties as non-configurable. Values of present properties can still be changed as long as they are writable.
Notice that freeze
is shallow, you have to do a deepFreeze
to make it a real constant. And there is no error throwing out when you trying to change the freezed object’s property.
keep updating