explain the function javascript (2)

2010-11-18  来源:本站原创  分类:Web  人气:91 

Connected to a:

Recursive function:

Recursive function is a function of the body in its own function calls itself. Recursive function must be careful not handled properly, will be the program enters an endless loop. Recursive function is only used under certain circumstances, such as dealing with factorial problem.

For example:

<head>

<script>

function f (num) {

if (num <= 1) {

return 1;

}

else {

return f (num-1) * num;

}

}

</ Script>

</ Head>

<body>

<script>

alert ('10! the result is: '+ f (10));

</ Script>

</ Body>

javascript built-in functions:

In addition to the custom javascript function, you can also use the built-in functions, these functions are functions provided by javascript language itself.

1.parseInt () function.

The main function is to first convert the string to a number of figures, if the string does not begin with a number, then it will return NaN.

parseInt (StringNum, [n])

StringNum need to convert a string to an integer.

[N]: provide 2 ---- 36 digits between the decimal saved. This parameter is not required in the function.

2.parseFloat () function.

The function and paeseInt similar, but it is to convert a string into a floating-point numbers.

3.isNaN () function.

This function is to verify whether a value NaN. If so, then return true; otherwise, returns false.

4.isFinite () function.

Mainly used to test whether an expression is infinite.

Syntax:

isFinite (Num);

5.encodeURI () function.

Returns a URI encoded string results.

Syntax:

encodeURI (url);

url: the address of network resources must be transformed into a string.

6.decodeURI () function.

Once you are used to decode the string as a URI string and return the original.

Syntax:

decodeURI (url);

相关文章
  • explain the function javascript (2) 2010-11-18

    Connected to a: Recursive function: Recursive function is a function of the body in its own function calls itself. Recursive function must be careful not handled properly, will be the program enters an endless loop. Recursive function is only used un

  • explain the function and the use of javascript onsubmit 2010-03-24

    explain the function and the use of javascript onsubmit Html code <! - function uploadFile () ( var cName = document.all.cName; document.forms [0]. action = "fileUpload.do? cName =" + cName.value; return true; ) -> <! - function uploadF

  • Learning JavaScript must-(a), let your js in the function, javascript built-in objects, this concept and not confuse the relationship between 2010-04-04

    Function is the basis for modular program design, preparation of complex Ajax applications, you must have a deeper understanding of the function. javascript function in a language different from the other, each function is as an object is the mainten

  • calculated according to age, function, javascript date 2010-04-23

    javascript date calculated according to age, function code is as follows: // Given birth date, calculate age function ages(str) { var r = str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/); if(r==null)return false; var d= new Date(r[1],r[3]-1,r[4]);

  • understanding of anonymous function javascript, js function included in parentheses as (function (){}) 2010-09-03

    Code: (Function () ( / / Here to ignore all the realization of jQuery })(); (Function () (/ / here ignore all realize })(); jQuery Six months ago, when the initial contact with jQuery, I like everyone else is excited to see what kind of source. Howev

  • Chapter JavaScript function 2010-05-03

    JS use the method requires attention to several areas: There any way to return value, if not explicitly return a value, its return value is undefined . Method definition, the parameter list can write the variable names on OK, for example: diff (iNum1

  • Eval function in Javascript in the use of 2010-07-19

    Javascript Eval function using JavaScript there are many small tricks to make programming easier. One is the eval () function, this function can be a string as a JavaScript expression to execute it the same. Give a small example var the_unevaled_answ

  • javascript function is programmed 2010-10-25

    Introduction Did you know that JavaScript is actually a functional programming language? This guide will teach you how to use JavaScript's functional characteristics. Requirements: JavaScript and you should already have a basic understanding of DOM.

  • Chapter 4 Core Series JavaScript function 2010-04-18

    Chapter function Function, the C-like procedural language, is the top entity in Java / C + + like object-oriented languages, were packing up the object, commonly known as the object. In JavaScript, the function itself and any other built-in objects a

  • Daquan set of JavaScript function 2010-08-05

    Daquan set of JavaScript function javascript provides many functions for the developers, the following gives a brief introduction, more detailed information, see Visual InterDev provides online help. A total of javascript function can be divided into

  • JavaScript (1) 2009-03-24

    Original: Lee warfare (leadzen). Shenzhen 2008-2-23 Programming the world exist only two basic elements, one is data, a code. Programming world is in the data and code in a web of tangled displays unlimited vigor and vitality. Data is inherently quie

  • Wu first javascript 2009-04-11

    http://www.cnblogs.com/leadzen/archive/2008/02/25/1073404.html Classic Introduction Programming the world exist only two basic elements, one is data, a code. Programming world is in the data and code in a web of tangled displays unlimited vigor and v

  • Object-Oriented JavaScript 2009-04-26

    Object-oriented focus on several major keywords: package, inheritance, polymorphism, object-oriented to start JavaScript Packaging: javascript to create the object model, individuals think through the closure to be on the up are the true meaning of t

  • JavaScript object model - implementation of model 2009-05-18

    http://www.cnblogs.com/RicCC/archive/2008/02/15/JavaScript-Object-Model-Execution-Model.html Cow too, and it is the browser developers. . . . Data Type <br /> The basic data types are basic data types of the JS implementation language of the bottom.

  • Named function expressions demystified 2010-04-01

    Known function expression (Named function expressions demystified) Original Address http://yura.thinkweb2.com/named- function-expressions / (Such as translation can be found in mail to my mailbox yangliang at vip.qq.com) by Juriy "kangax" Zaytse

  • JavaScript can multi-threaded? In-depth understanding of JavaScript regular mechanism 2010-05-15

    Transfer from: http://www.phpv.net/html/1700.html The setTimeout and setInterval JavaScript are two very easy ways to deceive the feelings of others, because we often think that call will begin according to the established manner, I think many people

  • JavaScript garbage collection 2010-06-05

    If you can not afford to use nested functions will not release the memory recall function of memory, I can assure normal circumstances, javascript does not recall any memory that is running the script for the release of the launch or re-initialize on

  • javascript object-oriented technology infrastructure (VI) (reproduced) 2010-10-14

    Original: javascript object-oriented technology infrastructure (VI) Scope, closures, analog private property first to mention briefly about the variable scope, we are familiar with these things, so no details. Js code var sco = "global"; / / glo

  • JavaScript scope chain 2010-10-22

    Scope of program development is an important part. javascript program each byte is run in this or that context (execution context) in the implementation. You can imagine the context of the code of these neighbors, they can be specified to each line o

  • JavaScript object models - Execution Model (Note 3) 2010-12-10

    Execution Model Execution context (Execution Context) Introduction JavaScript code to run there where the execution context, it is a concept, a mechanism used to complete the JavaScript runtime scope, survival and other aspects of treatment. Executio