These two days to see the GitHub of a great God, know that he is more interested in the algorithm, looked at one of the algorithm to calculate the number of steps, feeling this is a bit interesting, so I realized one.
Algorithm description and
Before the interview front end, encountered an interview problem, there was no thought so did not answer out, today organized a bit and everyone share under:
The original title is: Use the object method to create a 2x2 table (table), the second row
The array of Javascript arrays, both an array and a dictionary (Dictionary).
Let's take a look at the use of arrays.
Copy Code code as follows:
var a = new Array ();
A[0] = "Acer";
A[1] = "Dell";
for (var i in a) {
alert (i)
As the title shows, look at the example below.
(You can use the Chrome browser and then f12/or right button to review the elements.) Pull up the developer tool and enter the console console input.(Tips: When the console is entered, Shift+enter can
Adapter Mode description
Description: Adapter mode, generally for the interface to be used, does not conform to the application or use of this system, but need to introduce the middle of the adaptation layer class or object situation;
Scene:
Do not say much nonsense, directly to the code, know what to do with the small partners directly away.
Copy Code code as follows:
Util=function () {
return {
$:function (ID) {
return document.getElementById (ID);
},
Trim:function
The most common occurrence of a JavaScript value type conversion is the conversion of string and number between the two types of values.
You can convert a number value to a string by calling 4 functions (in fact, JS converts the number value to
In JavaScript, object conversion to Boolean is very simple: all object converts to Boolean are true; even new Boolean (false) Such an object is still true after conversion to Boolean.
Copy Code code as follows:
var x = new Boolean
The last time the Observer model was studied, many articles said it was also called subscribe/publish (Publish/Subscribe mode). There are some differences between the two patterns in the JavaScript design pattern book. The book reads as follows:
Usually our website will load some JS code, statistics ah, Google ads Ah, Baidu Alliance Ah, Ali mother Advertising code Ah,A heap, finally make the page loading speed is very slow, very slow.
Solution: Change the way a JS contains, so that the
The examples in this article describe the array sort and reverse usage in JavaScript. Share to everyone for your reference. The specific analysis is as follows:
The sort () method is used to sort the elements of an array.
Reverse () to reverse the
In JavaScript, there are four ways to check whether an object o owns property x:
1. "X" in O. The in operator can be used to check if there is an X in Object o. X can be the object itself (Own property), or it can be inherited from a prototype
About string test splitting in regular expressions. We generally have test () and Exec () Two methods, the difference between the two methods I do not elaborate here, mainly is the test () returns a Boolean value, EXEC () returns a matching array of
As with the Java language, you can save objects by serializing and deserializing them in JavaScript. In the ECMAScript 5 standard, Object serialization in JavaScript is accomplished by Json.stringify (), while deserialization is achieved by
This section describes how to implement a simple four-bit random number function by using a code example.A simpler way to do this is to randomly extract four characters from numbers and letters.
The code example is as follows:
function only
In JavaScript, you can use classes (class) to implement Object-oriented programming (object Oriented programming). However, the classes in JavaScript are different from Java, and they are defined and used differently.
Definition of classes in
Original topic:
Given a sequence of unordered integers, find the longest sequence of consecutive digits.
For example:
Given [100, 4, 200, 1, 3, 2],
The longest sequential number sequence is [1, 2, 3, 4].
The solution to the side dishes:
Are some commonly used functions, there is no more nonsense, small partners to see their own understanding
The code:
Copy Code code as follows:
Cookies
function Setcookie (name, value, Iday)
{
if (Iday!==false)
{
var odate=new
The example in this article describes how JavaScript uses a for-loop batch registration event that does not correctly get indexed values. Share to everyone for your reference. The specific analysis is as follows:
Many friends may encounter a
This example describes the way JavaScript restricts users to only Chinese characters. Share to everyone for your reference. The implementation methods are as follows:
To validate a function we must understand that if it is a Chinese character, the
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service