function type (obj) { return Object.prototype.toString.call (obj). Slice (8,-1). toLowerCase ()}
The implementation of the type function is used to identify standard types and built-in object types, with the following syntax:
var t = type (obj);
Examples of use are:
- var t = Type (1) //t=== "number"
- var t = Type (new number (1)) //t=== "number"
- var t = Type ("abc") //t=== "string"
- var t = Type (new String ("abc")) //t=== "string"
- var t = Type (true) //t=== "boolean"
- var t = type (undefined) //t=== "undefined"
- var t = type (null) //t=== "null"
- var t = Type ({}) //t=== "Object"
- var t = Type ([]) //t=== "array"
- var t = Type (new date) //t=== "Date"
- var t = Type (/\d/) //t=== "RegExp"
- var t = Type (function() {}) //t=== "function"
The Object.create (proto) method, defined in ES5, creates and returns a new object that is prototyped with the incoming proto object.
The syntax is as follows:
Object.create (Proto) (note: The second parameter is ignored)
proto--as a prototype object for newly created objects
Examples of use are:
var a = Object.create ({x:1, y:2});
function (obj) { varfunction() {}; = obj; return New F ();}
Object.create is not supported in some browsers, please give the Object.create compatible implementation.
function (obj) { varThis, = arguments; return function () { 1) }}
function Fibonacci (n) { if (n = = 0) {return 0; Else if (n = = 1) {return 1; Else { return (Arguments.callee (n-1) + Arguments.callee (n-2));} }
functionSearch (ARR,DST) {varType = Object.prototype.toString.call (arr). Slice (8,-1); if(Type! = ' Array '){ ThrowTypeError (' Object prototype may only is an Array ') } varLen =arr.length; if( !Len) { return-1; } varL = 0; varH = len-1; while(L <=h) { varm = Math.floor ((h+l)/2);if(Arr[m] = =DST) { returnm; }Else if(DST < arr[m]) {//left Half partH = m-1; }Else{//Right Half partL = m + 1; } }}vararr = [1,2,4,6,7,9,19,20,30,40,45,47];alert (arr,45))
JS Micro Professional Homework Answer