child class instances might be affected by a property that has a reference type value on the prototype object (because the parent class's properties are all copied over on the subclass, the Parent property is overwritten). But in this way, subclasses extend inconvenient when we want to extend the parent class, such as when the parent class becomes a function Sup (a, B). So, here's an improved notation (the idea I've been told by an interviewer):Sup.apply (this, arguments);Second, Sub.prototype.
This article analyzes the JS front-end pen test. Share to everyone for your reference, specific as follows:
1. How do I create an array based on a comma-delimited string? Please create an array for the following string and access the third element: "Cats,dogs,birds,horses"
Knowledge Points: Conversion of arrays and strings. Review the Split () method. Splits a string into an array of strings (the string i
The company's JS pen Test ~ You can the JS Foundation in prison. Hey heh code 1 var flag = true;2 var flag2 = true;3 if (flag = = True)4 {5 var i = 0;67 J = 1;89 if (Flag2 = = True)10 {One for (var m = 0 M 12 {1314}15}16}17alert (i);Alert (j);Alert (m);
Output 0, 1, 10
var x = 1;function Scopetest () {alert (x);}Scopetest (); Output 1
Output 1
var x = 1;functio
First, today in the group saw a few students sent a few words about JS Pen test, take to study, although they have seen the high-level program design, also read the JavaScript language essence, since the JS still have some understanding, but really encountered problems, found and can not be mastered, master not solid. Take this opportunity to review and learn tog
regular, what is the use ofRegular: Also called rules, so that computers can read human rules.* Which areas of the front end are used in regular?such as the registration page to enter the user name, we give a set of rules to determine whether he entered the rightRangeRegular is used to manipulate strings (i.e. don't use him to manipulate objects or anything)* How to write?Regular is also a system object, like arrays, JSON, there is a ruleabbreviated VAR re=//; Write only two slash, the browser
definedalert (b); // The equivalent of a global variable can be accessed // at this time the above code is equivalent to the following code varfunction aaa () { = ten; var a = b;} aaa (); alert (a);//error alert (b);//103. Variable search is the nearest principle, find the nearest var definition, the nearest can not find the words in the outer look.var a=10; function aaa () { alert (a); var a=20; } AAA (); // undefined Nearest principle find var definiti
a value is returned function Add (n) { var f=function(m) { return Add (n+m); }; f.tostring=f.valueof=function() { return n; }; return F;}View Code7 Variable Promotionif inch window)) { var a = 1;} alert (a);// [alert:undefined]View Answer8 Variable objectsvar a = 1, function A (x) { A (--x); }; alert (a);// [Alert:1] // precedence: Function parameters > Function declarations > variable declarations // equivalent to function expression b = funct
This article summarizes the JS Classic regular expression of the pen test. Share to everyone for your reference, specific as follows:
I. Review the traditional operation of strings
How to get a numeric character in a string and output it as an array, as
Dgfhfgh254bhku289fgdhdy675gfh
Output [254,289,675]
Analysis: Loop The Charat () method to get each substring, to determine whether he is between 0~9, i
executed; | | The expression on the left returns the value if the converted Boolean is true, returns the expression return value directly and no longer executes the right-hand expressionWith the above two points, the first two tests are relatively easy to understand, and for 1a=2, the actual equivalent to-(1a) =2--undefined=2, execution will be error, as long as the a=2 with parentheses priority execution can be normal operation, where a= The return value of 2 is 2, so the value of the final ex
sentence to execute new new fun (). GetName (); The execution order should be like this, first new out of the fun function of an instance, and then new a fun function instance of the GetName function, here we know getName function has been replaced by the result 3, New executes the code in the GetName function code console.log (3); the output, as for new New Fun (). GetName () Returns an instance of the GetName function. In fact, the fifth sentence means that the result of the return is differe
accessed outside of Func.5. Variable declaration earlier than code run (scoping and hoisting)1 var uname = ' Jack '2function Change () {3 // ? 4 var uname = ' Lily '5 alert (uname)6}7 Change ( )It is easy to be confused here is the first alert, if you think that the function change has been declared assignment, this should be jack, the actual function is also var once (although Var is behind), the pre-parsing will still be undefined. This is also why the book suggests that variable
, because the array sort by default is the comparison by character:Method One: var arr = []; Store non-repeating random number var n; while (Arr.length Method Two: var arr = []; Store all possible numbers for (var i=0;iMethod Two of the idea and method of a distinctly different, here is the whole range of the integer stored in arr, and then call--sort (order scrambled)--slice (take the first 10 elements)--sort (sorted by size return)(7) How to make all browsers compatible with ES5 array for
[, thisArg])Each element of an array, called the definition of a callback function, returns a list containing the resultParameters:Array1: Must. An Array objectCALLBACKFN: Must. A callback function that accepts up to three parameters (the value of the array element, the index of the array element, the array object containing the element)Thisarg: Optional.The original example is equivalent to[Parseint ("1", 0), parseint ("2", 1), parseint ("3", 2)]Analysis:1 by decimal conversion Output 11 is not
Two JS pen questions:
VaR tempb = function () {This. x = 1; this. getx = function () {return this. x ;}}VaR tempn = function () {This. x = 2 ;}VaR T = new tempb ();VaR G = new tempn ();Alert (T. getx ());
G. getx = T. getx;
Alert (G. getx ());
G. getx = function () {return T. getx ();}
Alert (G. getx ());
Write the execution result:
VaR P = 12;VaR result = (function (x, y, z ){This. tempx = 10;If
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.