ECMAScrpit 6 - Object

Object

The Object constructor creates an object wrapper. Methods of the Object constructor

  1. Object.assign() -Object.assign(target, ...sources)

    1. Copies the values of all enumerable own properties from one or more source objects to a target object.

    2. The Object.assign() method only copies enumerable and own properties from a source object to a target object.

  2. Object.keys() - Object.keys(obj)

    1. The Object.keys() method returns an array of a given object's own property names, in the same order as we get with a normal loop.

  3. Object.values() - Object.values(obj)

    1. The Object.values() method returns an array of a given object's own enumerable property values, in the same order as that provided by a for...in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well).

  4. Object.is() - Object.is(value1, value2)

    1. Object.is() determines whether two values are the same value.

Number& Math

The Number JavaScript object is a wrapper object allowing you to work with numerical values. A Number object is created using the Number() constructor. A primitive type object number created using the Number() function.

  1. Number.isNaN()

    • Determine whether the passed value is NaN.

  2. Number.isFinite()

    • Determine whether the passed value is a finite number.

  3. Number.isInteger()

    • Determine whether the passed value is an integer

  4. Number.isSafeInteger()

    • Determine whether the passed value is a safe integer

  5. Number.parseFloat()

    • The value is the same as parseFloat() of the global object.

  6. Number.parseInt()

    • The value is the same as parseInt() of the global object.

String&RegExp

The String global object is a constructor for strings or a sequence of characters.

  1. String.prototype.trim()

    • Trims whitespace from the beginning and end of the string. Part of the ECMAScript 5 standard.

  2. String.prototype.substring()

    • The substring() method returns the part of the string between the start and end indexes, or to the end of the string.

  3. String.prototype.slice()

    • The zero-based index at which to begin extraction

    • The slice() method extracts a section of a string and returns it as a new string, without modifying the original string.

Array

The JavaScript Array object is a global object that is used in the construction of arrays; which are high-level, list-like objects.

[element0, element1, ..., elementN]
new Array(element0, element1[, ...[, elementN]])
new Array(arrayLength)

标签: none

添加新评论