Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by rwniceing
at 2024-08-26 04:32:06
Point:500 Replies:6 POST_ID:829195USER_ID:12079
Topic:
JavaScript;Miscellaneous Programming;jQuery
I get confused with the terminology, constructor, in javascript , it always show in javascript
document or internet article.
Question-1
For example,
function test() {}
var b= new test()
where test() is function constructor always described in those article What is constructing ?
Question-2
var mesg="hello";
console.log(mesg); //hello
var mess = new String("hello") ;
console.log(mesg) //String{0:"h",1:"e",2:"l",3:"l",4:"o",Length:5}
console.log(mesg.constructor); //function String(){ [ native code ] }
What is mesg constructing from mesg.constructor ? What there is [native code] meaning ?
What is native meaning in javascript( i.e. bulit-in code or function) ?
Question-3.
Could we show all String function code inside instead of [native code], OR it is not allowed on browser ?
Question-4.
Is it exactly same meaning of constructor in javascript as in C++ such using "::"
Please advise
Rwniceing
document or internet article.
Question-1
For example,
function test() {}
var b= new test()
where test() is function constructor always described in those article What is constructing ?
Question-2
var mesg="hello";
console.log(mesg); //hello
var mess = new String("hello") ;
console.log(mesg) //String{0:"h",1:"e",2:"l",3:"l",4:"o",Length:5}
console.log(mesg.constructor); //function String(){ [ native code ] }
What is mesg constructing from mesg.constructor ? What there is [native code] meaning ?
What is native meaning in javascript( i.e. bulit-in code or function) ?
Question-3.
Could we show all String function code inside instead of [native code], OR it is not allowed on browser ?
Question-4.
Is it exactly same meaning of constructor in javascript as in C++ such using "::"
Please advise
Rwniceing
Author: rwniceing replied at 2024-08-29 01:23:25
Thanks for your reply
Author: rwniceing replied at 2024-08-26 08:43:53
The question-2 answer is referred to question-1 rely and tutorial constuctor javascript link at http://dmitrysoshnikov.com/ecmascript/javascript-the-core/
and Question-3 and native code is referenced in , for example, for chrome browser V8 engine which is written in C++ at https://code.google.com/p/v8/
and Question-3 and native code is referenced in , for example, for chrome browser V8 engine which is written in C++ at https://code.google.com/p/v8/
Expert: jkr replied at 2024-08-26 08:36:16
Removing C++ zome reference, since it's unrelated. Please post in related zones only,
Author: rwniceing replied at 2024-08-26 06:23:06
You're answering Q1 and Q4
In your reply to question 1,
string.prototype = { constructor: function(){ [native code]} }
So constructor is just object string protoptype's property which is named with constructor.
Accessing Sting.constructor will show function(){[native code]} such as in quesiton-2
So constructor is just built-in object prototype property, nothing is special, Right ?
To question-4, I think so, other epxerts agree it ?
Could you also answer Q2 and Q3, thanks for your reply
Rwniceing
In your reply to question 1,
string.prototype = { constructor: function(){ [native code]} }
So constructor is just object string protoptype's property which is named with constructor.
Accessing Sting.constructor will show function(){[native code]} such as in quesiton-2
So constructor is just built-in object prototype property, nothing is special, Right ?
To question-4, I think so, other epxerts agree it ?
Could you also answer Q2 and Q3, thanks for your reply
Rwniceing
Assisted Solution
Expert: trinitrotoluene replied at 2024-08-26 06:07:50
250 points EXCELLENT
The constructor property returns the constructor function for an object. This enables you to decide the type of the function object.
Accepted Solution
Expert: trinitrotoluene replied at 2024-08-26 06:05:03
250 points EXCELLENT
constructor can be viewed as a prototype from which an object is created. You can retrieve the constructor for a function object and it can be used if you need to relate a function object to its creation.
In a way it is similar to the constructor concept that is seen in other OO languages like C++ and Java.
Take a look at
http://javascript.info/tutorial/constructor
In a way it is similar to the constructor concept that is seen in other OO languages like C++ and Java.
Take a look at
http://javascript.info/tutorial/constructor