


Some detailed analysis of parameters passed in new Object in js_javascript skills
The object constructor it generates is still the constructor of the passed parameter object. The consequence of this is that although the object is new Object, its constructor is not necessarily Object.
function Person(){this.name='jack' ;}
var w = new Object(window),
d = new Object(document),
p = new Object(new Person());
console.log(w .constructor); //-> Window
console.log(d.constructor); //-> HTMLDocument
console.log(p.constructor); //-> Person
2, the parameter is a basic type object, such as a string (String), a number (Number), a Boolean value (Boolean), which is packaged into an object (converted into its corresponding packaging class) and returned .
var s = new Object('hello' ),
n = new Object(22),
b = new Object(true);
console.log(typeof s); //-> Object
console.log (typeof n); //-> Object
console.log(typeof b); //-> Object
console.log(s.constructor); //-> String
console.log(n.constructor); //-> Number
console.log(b.constructor); //-> Boolean
As can be seen from the above, when When passing parameters, the constructor of the object generated using new Object does not necessarily point to Object. It will point to Object only by chance, such as
var obj1 = new Object,
obj2 = {};
var o1 = new Object(obj1);
o2 = new Object( obj2);
console.log(o1.constructor); //-> Object
console.log(o2.constructor); //-> Object
The above can explain why the following code in jquery1.4 returns false
function Person(){this.name='jack';}
var p = new Person();
$.isPlainObject(new Object(4)); //-> false
$.isPlainObject(new Object('hello')); //-> false
$.isPlainObject(new Object(true)); //-> false
$.isPlainObject(new Object( p)); //-> false

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Object to byte and byte to Object Today we will realize how to convert from Object to byte and how to convert from byte to Object. First, define a class student: packagecom.byteToObject;importjava.io.Serializable;publicclassstudentimplementsSerializable{privateintsid;privateStringname;publicintgetSid(){returnsid;}publicvoidsetSid(in

1. Introduction to the Object class Object is a class provided by Java by default. Except for the Object class, all classes in Java have inheritance relationships. By default, it will inherit the Object parent class. That is, objects of all classes can be received using the reference of Object. Example: Use Object to receive objects of all classes classPerson{}classStudent{}publicclassTest{publicstaticvoidmain(String[]args){function(newPerson());function(newStudent());}public

Java uses the getClass() function of the Object class to obtain the runtime class of the object. In Java, each object has a class, which defines the properties and methods of the object. We can use the getClass() function to get the runtime class of an object. The getClass() function is a member function of the Object class, so all Java objects can call this function. This article will introduce how to use the getClass() function and give some code examples. use get

The relationship between basic data types and Object. I know everyone has heard that Object is the base class of all types, but this sentence is actually not correct, because the basic data types in Java have nothing to do with Object. Here are some examples For example, when calling the swap method, you cannot directly pass the int type to the swap(Objectobj) method, because Object actually has nothing to do with the basic data type. At this time, a finds that our types do not match, so it automatically wraps it. It has become an Integer type. At this time, it can be contacted with Object and the swap method can be successfully called. Object, a wrapper class of basic data types

PHPNotice: Tryingtogetpropertyofnon-object Solution When you are developing in PHP, you may encounter this error message: "Notice: Tryingtogetpropertyofnon-object." This error message is usually due to you using an uninitialized object, or It's because your object has lost its reference in a certain piece of code and cannot access the properties correctly.

Solution to PHPNotice: Tryingtogetpropertyofnon-object In the process of writing code in PHP, we may encounter the error message "Tryingtogetpropertyofnon-object". This error message usually occurs because we are trying to access a non-existent object property, causing an error in the code. This error message usually appears in the following situations: The object does not exist

1. Concept In the Java language, the "new" expression is responsible for creating an instance, in which the constructor is called to initialize the instance; the return value type of the constructor itself is void, not "the constructor returns the newly created Object reference", but the value of the new expression is a reference to the newly created object. 2. Purpose: Create an object of a new class. 3. Working mechanism: Allocate memory space for object members, and specify default values. Explicitly initialize member variables, perform construction method calculations, and return reference values. 4. Instance new operation often means opening up new memory in the memory. The memory space is allocated in the heap area in the memory. It is controlled by jvm and automatically manages the memory. Here we use the String class as an example. Pu

Introduction to the two-tier data structure of Redis. One of the reasons for the high performance of redis is that each of its data structures is specially designed and supported by one or more data structures. These flexible data structures are relied upon to improve reading performance. Fetch and write performance. If you want to understand the data structure of redis, you can discuss it from two different levels: The first level is from the user's perspective. This level is also the calling interface that Redis exposes to the outside, such as: string, list, hash ,set,sortedset. The second level is from the perspective of internal implementation, which belongs to the lower level implementation, such as: dict, sds, ziplist, quicklist, skiplis
