1. Array Clone , Use slice() Method

var a1 = [1,2,3,4];

var a2 = a1.slice();

2. Force the value of a variable to bool type , Front double sense exclamation mark !!

var a = ...

var b = !!a;

3. Force a variable value to be converted to number type , Pre plus sign +

var a = ...

var b = +a;

4. take arguments Convert to a real array , Array.prototype.slice.call

function func1(){

var array = Array.prototype.slice.call(arguments);

...

}

Javascript Tips (1) More articles about

  1. JavaScript skill & How to write it

    original text :JavaScript skill & How to write it JavaScript Tips : 1> State machine var state = function () { this.count = 0; this.fun = ...

  2. Javascript skill

    Javascript Array to CSV Format First, consider the following application scenarios , There is one Javscript The character type of ( Or numerical ) Array , Now you need to convert to a comma separated CSV Format file . Then we can use the following tips , The code is as follows : ...

  3. Winjs – Microsoft open source technology released JavaScript Component set

    Winjs It's a group launched by the developers of Microsoft open source technology JavaScript Components , Include  ListView.ListView.Tooltip.DatePicker.Ratings wait , help Web Developer ...

  4. ( translation )12 Simple ( But powerful ) Of JavaScript skill ( Two )

    Link to the original text : 12 Simple (Yet Powerful) JavaScript Tips Other links : ( translation )12 Simple ( But powerful ) Of JavaScript skill ( One ) Powerful immediate call function expression ( what ...

  5. ( translation )12 Simple ( But powerful ) Of JavaScript skill ( One )

    Original link : 12 Simple (Yet Powerful) JavaScript Tips I will introduce and analyze 12 A simple but powerful JavaScript skill . These skills, all of them JavaScript All programmers ...

  6. 21 A collectable Javascript skill

    1  Javascript Array to CSV Format First, consider the following application scenarios , There is one Javscript The character type of ( Or numerical ) Array , Now you need to convert to a comma separated CSV Format file . Then we can use the following tips , Code such as ...

  7. 12 A very useful JavaScript skill

    In this article , I will share 12 A very useful JavaScript skill . These tips can help you reduce and optimize your code . 1) Use !! Convert variables to Boolean types   Sometimes , We need to check if some variables exist , Or whether it has a valid value , So that ...

  8. Native JavaScript Skills Collection

    Native JavaScript Skills Collection Address :http://itindex.net/detail/47244-javascript

  9. Native JavaScript Skills Collection 100 individual

    Native JavaScript Skills Collection 1. Native JavaScript Achieve string length interception function cutstr(str, len) { var temp; var icount = 0; var p ...

Random recommendation

  1. linux Several reliable ways to make programs run in the background

    We often have this problem , use telnet/ssh Logged in to the remote Linux The server , Some time-consuming tasks were run , As a result, due to the instability of the network, the task failed halfway . How to close the terminal window after the command is submitted / The network is disconnected ...

  2. Bootstrap grid system

    One . grid system Responsive grid system with screen or view (viewport) Increase in size , The system will automatically divide it into the most 12 Column . Two . The basic structure <div class="container"> &l ...

  3. 【 Luogu P2513】 Reverse order pair sequence

    The prefix and . Rolling array optimization dp f[i][j] Before presentation i Number , The inverse logarithm is j Number of alternatives We know , In the k Put the first place i Number , The inverse logarithm obtained in one step is i-k Before i Number , The maximum number of reverse logarithms that can be produced is i individual , least 0 individual , Can be transferred to ...

  4. swift—— Start page internationalization : Step by step dynamic loading startup page image , Load text on startup

    Due to the needs of the company , Request to make an international startup page , because app I got internationalized, too , All that's left is the startup page , Baidu, ah, Google, a lot of answers are not satisfactory , Finally, I saw my colleagues finish , I also asked about the specific measures , Decide to share with those in need , So you don't have to talk to me ...

  5. ld: framework not found AGCommon About the three party library into Problem solution !!

    ld: framework  not found AGCommon clang:error:linker command failed with exit code 1 (use -v to see ...

  6. javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure Solution

    This is jdk As a result of ,jdk There's a jce My bag , Access caused by security mechanism https Will report a mistake , There are alternatives on the official website jar package , Just replace it Catalog %JAVA_HOME%\jre\lib\security Inside local_ ...

  7. javascript in window.open() And window.location.href The difference between

    window.open("www.baidu.com");  It just means to open this page , It's not about opening and refreshing baidu.com window.location.href="www. ...

  8. Simple implementation contentOS The next boot automatically starts tomcat

    I've seen a lot of writing on the Internet tomcat Examples of booting and booting , Many of them have written a more complicated step . Find a simpler one . The first edit vi /etc/rc.d/rc.local Add... At the end export JDK_HOME=/u ...

  9. .Net Language APP Development platform ——Smobiler Study log : How to set the page title

    1. modify Mobile Form Of TitleText Properties of Enter the title you want to display , Pictured 1: 2. modify Mobile Form Of TitleStyle attribute These include Image attribute ( Form icon ).BackColor Belong to ...

  10. stm32 HAL Library programming driver control file &lt;stm32f1xx_hal_conf.h&gt; The enabling method of

    @2019-01-25 [ Notes ] tools . Easy to control . Easy to configure . Efficient : Driver control file <stm32f1xx_hal_conf.h> The driver module is enabled by STM32CubeMX Tool configuration enables