JavaScript: The Definitive Guide, Sixth Editio javaScript权威指南(第6版) pdf 文字版-文字版, javascript电子书, 和javascript 有关的电子书:

Array.unshift()

Array.unshift()


insert elements at the beginning of an array

Synopsis

array.unshift(value, ...)

Arguments

value, ... One or more values that are inserted at the start of array.

Returns

The new length of the array.

Core JavaScript Reference | 739

Boolean

Description

unshift() inserts its arguments at the beginning of array, shifting the existing elements to higher indexes to make room. The first argument to shift() becomes the new element 0 of the array; the second argument, if any, becomes the new element 1; and so on. Note that unshift() does not create a new array; it modifies array directly.

Example

unshift() is often used in conjunction with shift(). For example:

var a = []; // a:[] a.unshift(1); // a:[1] Returns: 1 a.unshift(22); // a:[22,1] Returns: 2 a.shift(); // a:[1] Returns: 22 a.unshift(33,[4,5]); // a:[33,[4,5],1] Returns: 3

See Also

Array.shift()

Boolean

support for boolean values Object → Boolean

Constructor

new Boolean(value) // Constructor function Boolean(value) // Conversion function

Arguments

value

The value to be held by the Boolean object or to be converted to a boolean value.

Returns

When invoked as a constructor with the new operator, Boolean() converts its argument to a boolean value and returns a Boolean object that contains that value. When invoked as a function, without the new operator, Boolean() simply converts its argument to a primitive boolean value and returns that value.

The values 0, NaN, null, the empty string "", and the undefined value are all converted to false. All other primitive values, except false(but including the string “false”), and all objects and arrays are converted to true.

Methods

toString()

Returns “true” or “false”, depending on the boolean value represented by the Boolean object.

valueOf()

Returns the primitive boolean value contained in the Boolean object.

Boolean.valueOf()

Description

Boolean values are a fundamental datatype in JavaScript. The Boolean object is an object wrapper around the boolean value. This Boolean object type exists primarily to provide a toString() method to convert boolean values to strings. When the toString() method is invoked to convert a boolean value to a string (and it is often invoked implicitly by JavaScript), JavaScript internally converts the boolean value to a transient Boolean object, on which the method can be invoked.

See Also

Object

Boolean.toString()

convert a boolean value to a string Overrides Object.toString()

Synopsis

b.toString()

Returns

The string “true” or “false”, depending on the value of the primitive boolean value or Boolean object b.

Throws

TypeError

If this method is invoked on an object that is not a Boolean.

欢迎转载,转载请注明来自一手册:http://yishouce.com/book/1/28143.html
友情链接It题库(ittiku.com)| 版权归yishouce.com所有| 友链等可联系 admin#yishouce.com|粤ICP备16001685号-1