SlideShare une entreprise Scribd logo
1  sur  2
Télécharger pour lire hors ligne
JavaScript Quick Reference Card1.03

                                                                 /              3/2                          1.5             slice – returns array slice. 1st arg is start position. 2nd arg
                                                                                                                             is last position + 1
                                                                 %              3%2                          1               sort – alphanumeric sort if no argument. Pass sort
                                                                 ++             i = 2;                       3               function as argument for more specificity.
                                                                                i++1, ++i2                                   splice – discard and replace elements
                                                                 --             i = 2;                       1               unshift – append elements to start & return new length
           Copyright©, 2007-2009 BrandsPatch LLC                                i--1, --i2                                                         Date Object
                                       http://www.explainth.at    ==            3 = '3'                      true            get#
                                           Color key overleaf     ==            2 == 3                       false           getUTC#
                     Code Structure                               ===           3 === 3                      true            set#
var ...                                                                         3 === '3'                    false           setUTC#
//Global variable declarations                                                                                               where # is one of Date, Day, FullYear, Hours,
                                                                 <              2<3                          true
function funcA([param1,param2,...])                                             'a' < 'A'                    false           Milliseconds, Minutes, Month, Seconds, Time,
{                                                                                                                            TimezoneOffset
 var ...                                                         <=             2 <= 3                       true
                                                                                                                             toDateString – the date in English.
 //Local variable declarations – visible in nested
functions                                                        >              2>3                          false           toGMTString – the date & time in English.
                                                                 >=             2>3                          false           toLocaleDateString – the date in the locale language.
[function innerFuncA([iparam1,iparam2...])                                                                                   toLocaleString – date & time in the locale language.
{                                                                 =             i=2                          i is assigned
 var ...                                                                                                     the value 2     toLocaleTimeString – time in the locale language.
 //Variables local to innerFuncA                                                                                             toTimeString – time in English.
                                                                 +=             i+=1                         3
//your code here                                                                                                             toUTCString – date & time in UTC, English
}]                                                               -=             i-=1                         2
                                                                                                                             valueOf – milliseconds since midnight 01 January 1970,
                                                                 i*=            i*=3                         6               UTC
aName='ExplainThat!';                                                                                                                              Math Object
//implicit global variable creation                              /=             i/=2                         3
//your code here                                                                                                             E, LN10, LN2, LOG10E, LOG2E, PI, SQRT1_2, SQRT2
                                                                 %=             i%=2                         1               abs – absolute value
}
               Nomenclature Rules                                i = 2;j = 5;                                                #(n) - trigonometric functions
Function and variable names can consist of any                   && (AND)       (i <= 2) && (j < 7)          true            a#(n) - inverse trigonometric functions
alphanumeric character. $ and _ are allowed. The first                                                                       where # is one of cos, sin or tan
character cannot be numeric. Many extended ASCII                 || (OR)        (i%2 > 0) || (j%2 == 0)      false
                                                                                                                             ceil(n) – smallest whole number >= n
characters are allowed. There is no practical limit on
                                                                 ! (NOT)        (i==2) && !(j%2 == 0)        true
name length. Names are case-sensitive.                                                                                       exp(n) – returns en
If two or more variables or functions or a variable & a          i = 2;j = 7;                                                floor(n) – biggest whole number <= n
function are declared with the same name the last                & (bitwise)    i&j                          2               log(n) – logarithm of n to the base e
declaration obliterates all previous ones. Using a
                                                                                                                             max(n1,n2) – bigger of n1 and n2
keyword as a variable or function name obliterates that          | (bitwise)    i|j                          7
keyword.                                                                                                                     min(n1,n2) – smaller of n1 and n2
                                                                 ^(XOR)         i^j                          5
                  Visibility & Scope                                                                                         pow(a,b) - ab
Assignments without the use of the var keyword result            <<             2<<1                         4               random – random number between 0 and 1
in a new global variable of that name being created.             >>             2>>1                         1               round(n) – n rounded down to closest integer
Variables declared with the var keyword outwith the                                                                          sqrt(n) – square root of n
                                                            >>>        i=10 (binary 1010)      23
body of a function are global. Variables declared with                 i>>>2                                                                    Number Object
the var keyword inside the body of a function are local
                                                                                                                             MAX_VALUE - ca 1.7977E+308
to that function. Local variables are visible to all nested               Internal Functions
functions.                                                                                                                   MIN_VALUE – ca 5E-324
                                                            decodeURI - reverses encodeURI
Local entities hide globals bearing the same name.                                                                           NEGATIVE_INFINITY, POSITIVE_INFINITY
                                                            decodeURIComponent - reverses encodeURI...
                     Variable Types                                                                                          n.toExponential(m) – n in scientific notation with m
                                                                 encodeURI – encodes everything except :/?
                                                                                                                             decimal places.
string: var s = 'explainthat' or “explainthat”                   &;,~@&=$+=_.*()# and alphanumerics.
                                                                                                                             n.toFixed() - n rounded to the closest whole number.
number: var n = 3.14159, 100, 0...                               encodeURIComponent – encodes everything except
                                                                 _.-!~*() and alphaumerics.                                  n.toPrecision(m) – n rounded to m figures.
boolean: var flag = false or true
                                                                 escape – hexadecimal string encoding. Does not              Hexadecimal numbers are designated with the prefix
object: var d = new Date();                                                                                                  0x or 0X. e.g. 0xFF is the number 255.
                                                                 encode +@/_-.* and alphanumerics.
function: var Greet = function sayHello() {alert('Hello')}unescape – reverses escape                                                               String Object
JavaScript is a weakly typed language – i.e. a simple eval – evaluates JavaScript expressions                                length – number of characters in the string
assignment is sufficient to change the variable type. The
                                                                                                                             s.charAt(n) – returns s[n]. n starts at 0
typeof keyword can be used to check the current isNaN – true if the argument is not a number.
variable type.                                            isFinite – isFinite(2/0) returns false                             s.charCodeAt(n) – Unicode value of s[n]
                     Special Values                              parseInt - parseInt(31.5°) returns 31                       s.fromCharCode(n1,n2..) - string built from Unicode
                                                                                                                             values n1, n2...
The special values false, Infinity, NaN, null, true & parseFloat - parseFloat(31.5°) returns 31.5
undefined are recognized. null is an object. Infinity                                                                        s1.indexOf(s2,n) – location of s2 in s1 starting at
                                                                        Array Object                                         position n
and NaN are numbers.
                                                      length – number of elements in the array
                        Operators                                                                                            s1.lastIndexOf(s2) – location of s2 in s1 starting from
                                                                 concat – concatenates argument, returns new array.          the end
    Operator             Example                  Result
                                                                 join – returns elements as a string separated by            s.substr(n 1,n2) – returns substring starting from n1 upto
+              3+2                           5                   argument (default is ,)                                     character preceding n2. No n2 = extract till end. n1 < 0 =
               'explain' + 'that'            explainthat         pop – suppress & return last element                        extract from end.
-              3-2                           -1                  push – adds new elements to end of array & returns          s.toLowerCase() - returns s in lower case characters
                                                                 new length.                                                 s.toUpperCase() - care to guess?
*              3*2                           6
                                                                 reverse – inverts order of array elements
                                                                 shift – suppress & return first element
JavaScript Quick Reference Card1.03

                     Escape Sequences                      { alert(num);                                              ownerDocument – take a guess
n - new line, r - carriage return, t – tab character,       num--;}                                                style – CSS style declaration
 -  character, ' - apostrophe, '' - quote             }                                                          tagName – element tag type. Curiously, always in
uNNNN – Unicode character at NNNN                                                                                    uppercase
e.g. u25BA gives the character ►                          function doLoop(num){                                      textContent – the Firefox equivalent of innerText
                  JavaScript in HTML                       do{                                                                          location Object
External JavaScript                                               alert(num);                                         host – URL of the site serving up the document
                                                                  num--;                                              href – the entire URL to the document
<script type=”text/javascript” defer=”defer”
src=”/scripts/explainthat.js”></script>                    }while (num > 0);                                          pathname – the path to the document on the host
Inline JavaScript                                          }                                                          protocol – the protocol used, e.g. http
<script type=”text/javascript”>                                                                                       reload(p) - reload the document. From the cache if p is
//your code here                                           function forLoop(num){                                     true.
</script>                                                                                                             replace(url) – replace the current document with the
                                                           var i;
                          Comments                                                                                    one at url. Discard document entry in browser history.
                                                           for (i=0;i<num;i++){
/* Comments spanning multiple lines */                                                                                                   screen Object
                                                                  alert(num);
// Simple, single line, comment                                                                                       height – screen height in pixels
                                                           }
                Conditional Execution                                                                                 width – screen width in pixels
                                                           }
if (Condition) CodeIfTrue;else CodeIfFalse4                                                                                             window Object
Multiline CodeIf# must be placed in braces, {}                                                                        alert(msg) – displays a dialog with msg
                                                           break causes immediate termination of the loop.
switch (variable)                                                                                                  clearInterval(id) – clears interval id set by setInterval
                                                           loop statements after continue are skipped and the next
{                                                          execution of the loop is performed.                     clearTimeout(id) – clears timeout id set by setTimeout
case Value1:Code;                                                                                                  confirm(msg) – shows a confirmation dialog
                 break;                                    function forInLoop(){                                      print() - prints the window contents
case Value2:Code;                                          var s,x;                                                   prompt(msg,[default]) – shows prompt dialog,
                 break;                                                                                               optionally with default content. Returns content or null.
                                                           for (x in document)
.....                                                                                                                 setInterval(expr,interval) – sets repeat at interval ms.
                                                           {                                                          The function expr is evaluated5 .
default:Code;                                                  s=x + ' = ' + document[x];                             setTimeout(expr,time) Like setInterval but non-
}                                                              alert(s);                                              repeating. 5
variable can be boolean, number, string or even date.      }                                                                                   Notes
(condition)?(CodeIfTrue):(CodeIfFalse)                     }
                                                                                                                      1
                                                                                                                       Evaluates after use 2 Evaluates before use
Parentheses are not necessary but advisable
                                                                                                                     3
                                                                                                                       Zero-fill right shift 4 Note the semicolon!
                                                           This code is best tested in Opera which offers the option 5
                      Error Handling                                                                                   Passing arguments to function calls via expr is not well
                                                           of stopping the script at each alert. In place of
                                                                                                                     supported.
Method 1:The onerror event                                 document any JavaScript object or an array can be
                                                           used to loop through its properties/elements.              Color Coding
<script type=”text/javascript”>
                                                                                     return                           italics – user code blue – JavaScript Keywords
function whenError(msg,url,lineNo){
 //use parameters to provide meaningful messages           return causes immediate termination of the JavaScript red – Option object – JavaScript DOM object
                                                           function. If no value is returned, or if return is missing green – only numeric values blue - object properties
}                                                          the function return type is undefined.
                                                                                                                      green – object methods magenta – object events
window.onerror = whenError                                                      document Object                       Tested with Internet Explorer 6+, Firefox 1.5+ & Opera
</script>                                                  body - the body of the document                            9.1+.
Place this code in a separate <script>..</script> tag cookie - read/write the document cookies
pair to trap errors occurring in other scripts. This
technique blocks errors without taking corrective action. domain – where was the document served from?
                                                          forms[] - array of all forms in the document
                                                           images[] - array of all images in the document
Method 2:The try..catch..finally statement
                                                           referrer – who pointed to this document?
function showLogValue(num){
                                                           URL – the URL for the document
var s = 'No Error';
                                                           getElementById(id) – element bearing ID of id
try
                                                           getElementsByName(n) – array of elements named n
{if (num < 0) throw 'badnum';
                                                           getElementsByTagName(t) - array of t tagged
    if (num == 0) throw 'zero'; }
                                                           elements
catch (err)
                                                           write – write plain or HTML text to the document
{ s = err;
                                                           onload – occurs when the document is loaded
    switch (err) {
                                                           onunload – occurs when user browses away, tab is
    case 'badnum':num = -num;                              closed etc.
                      break;                                                    Element Object
    case 'zero':num = 1;                                   By element we mean any HTML element retrieved using
               break; }                                    the document.getElementBy# methods.
}                                                          attributes – all element attributes in an array
[finally{ alert([s,Math.log(num)]);}]                      className – the CSS style assigned to the element
}                                                          id – the id assigned to the element
The finally block is optional. The two techniques can be   innerHTML – HTML content of the element
used in concert.                                           innerText – content of the element shorn of all HTML
                           Looping                         tags. Does not work in Firefox
function whileLoop(num){                                   offset# – element dimensions (# = Height/Width) or
while (num > 0)                                            location(# = Left/Right) in pixels

Contenu connexe

Dernier

Unveiling the Future: Columbus, Ohio Condominiums Through the Lens of 3D Arch...
Unveiling the Future: Columbus, Ohio Condominiums Through the Lens of 3D Arch...Unveiling the Future: Columbus, Ohio Condominiums Through the Lens of 3D Arch...
Unveiling the Future: Columbus, Ohio Condominiums Through the Lens of 3D Arch...Yantram Animation Studio Corporation
 
毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree 毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree ttt fff
 
Design principles on typography in design
Design principles on typography in designDesign principles on typography in design
Design principles on typography in designnooreen17
 
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)jennyeacort
 
Call Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts Service
Call Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts ServiceCall Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts Service
Call Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts Servicejennyeacort
 
专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degreeyuu sss
 
Untitled presedddddddddddddddddntation (1).pptx
Untitled presedddddddddddddddddntation (1).pptxUntitled presedddddddddddddddddntation (1).pptx
Untitled presedddddddddddddddddntation (1).pptxmapanig881
 
FiveHypotheses_UIDMasterclass_18April2024.pdf
FiveHypotheses_UIDMasterclass_18April2024.pdfFiveHypotheses_UIDMasterclass_18April2024.pdf
FiveHypotheses_UIDMasterclass_18April2024.pdfShivakumar Viswanathan
 
PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024
PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024
PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024CristobalHeraud
 
2024新版美国旧金山州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
2024新版美国旧金山州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree2024新版美国旧金山州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
2024新版美国旧金山州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degreeyuu sss
 
How to Be Famous in your Field just visit our Site
How to Be Famous in your Field just visit our SiteHow to Be Famous in your Field just visit our Site
How to Be Famous in your Field just visit our Sitegalleryaagency
 
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一diploma 1
 
办理学位证(NTU证书)新加坡南洋理工大学毕业证成绩单原版一比一
办理学位证(NTU证书)新加坡南洋理工大学毕业证成绩单原版一比一办理学位证(NTU证书)新加坡南洋理工大学毕业证成绩单原版一比一
办理学位证(NTU证书)新加坡南洋理工大学毕业证成绩单原版一比一A SSS
 
西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造kbdhl05e
 
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
3D Printing And Designing Final Report.pdf
3D Printing And Designing Final Report.pdf3D Printing And Designing Final Report.pdf
3D Printing And Designing Final Report.pdfSwaraliBorhade
 
shot list for my tv series two steps back
shot list for my tv series two steps backshot list for my tv series two steps back
shot list for my tv series two steps back17lcow074
 
cda.pptx critical discourse analysis ppt
cda.pptx critical discourse analysis pptcda.pptx critical discourse analysis ppt
cda.pptx critical discourse analysis pptMaryamAfzal41
 
Mookuthi is an artisanal nose ornament brand based in Madras.
Mookuthi is an artisanal nose ornament brand based in Madras.Mookuthi is an artisanal nose ornament brand based in Madras.
Mookuthi is an artisanal nose ornament brand based in Madras.Mookuthi
 
PORTAFOLIO 2024_ ANASTASIYA KUDINOVA
PORTAFOLIO   2024_  ANASTASIYA  KUDINOVAPORTAFOLIO   2024_  ANASTASIYA  KUDINOVA
PORTAFOLIO 2024_ ANASTASIYA KUDINOVAAnastasiya Kudinova
 

Dernier (20)

Unveiling the Future: Columbus, Ohio Condominiums Through the Lens of 3D Arch...
Unveiling the Future: Columbus, Ohio Condominiums Through the Lens of 3D Arch...Unveiling the Future: Columbus, Ohio Condominiums Through the Lens of 3D Arch...
Unveiling the Future: Columbus, Ohio Condominiums Through the Lens of 3D Arch...
 
毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree 毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
Design principles on typography in design
Design principles on typography in designDesign principles on typography in design
Design principles on typography in design
 
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
 
Call Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts Service
Call Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts ServiceCall Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts Service
Call Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts Service
 
专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
 
Untitled presedddddddddddddddddntation (1).pptx
Untitled presedddddddddddddddddntation (1).pptxUntitled presedddddddddddddddddntation (1).pptx
Untitled presedddddddddddddddddntation (1).pptx
 
FiveHypotheses_UIDMasterclass_18April2024.pdf
FiveHypotheses_UIDMasterclass_18April2024.pdfFiveHypotheses_UIDMasterclass_18April2024.pdf
FiveHypotheses_UIDMasterclass_18April2024.pdf
 
PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024
PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024
PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024
 
2024新版美国旧金山州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
2024新版美国旧金山州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree2024新版美国旧金山州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
2024新版美国旧金山州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
How to Be Famous in your Field just visit our Site
How to Be Famous in your Field just visit our SiteHow to Be Famous in your Field just visit our Site
How to Be Famous in your Field just visit our Site
 
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
 
办理学位证(NTU证书)新加坡南洋理工大学毕业证成绩单原版一比一
办理学位证(NTU证书)新加坡南洋理工大学毕业证成绩单原版一比一办理学位证(NTU证书)新加坡南洋理工大学毕业证成绩单原版一比一
办理学位证(NTU证书)新加坡南洋理工大学毕业证成绩单原版一比一
 
西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造
 
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
 
3D Printing And Designing Final Report.pdf
3D Printing And Designing Final Report.pdf3D Printing And Designing Final Report.pdf
3D Printing And Designing Final Report.pdf
 
shot list for my tv series two steps back
shot list for my tv series two steps backshot list for my tv series two steps back
shot list for my tv series two steps back
 
cda.pptx critical discourse analysis ppt
cda.pptx critical discourse analysis pptcda.pptx critical discourse analysis ppt
cda.pptx critical discourse analysis ppt
 
Mookuthi is an artisanal nose ornament brand based in Madras.
Mookuthi is an artisanal nose ornament brand based in Madras.Mookuthi is an artisanal nose ornament brand based in Madras.
Mookuthi is an artisanal nose ornament brand based in Madras.
 
PORTAFOLIO 2024_ ANASTASIYA KUDINOVA
PORTAFOLIO   2024_  ANASTASIYA  KUDINOVAPORTAFOLIO   2024_  ANASTASIYA  KUDINOVA
PORTAFOLIO 2024_ ANASTASIYA KUDINOVA
 

En vedette

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

En vedette (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

2009 java script quick reference card v1.03

  • 1. JavaScript Quick Reference Card1.03 / 3/2 1.5 slice – returns array slice. 1st arg is start position. 2nd arg is last position + 1 % 3%2 1 sort – alphanumeric sort if no argument. Pass sort ++ i = 2; 3 function as argument for more specificity. i++1, ++i2 splice – discard and replace elements -- i = 2; 1 unshift – append elements to start & return new length Copyright©, 2007-2009 BrandsPatch LLC i--1, --i2 Date Object http://www.explainth.at == 3 = '3' true get# Color key overleaf == 2 == 3 false getUTC# Code Structure === 3 === 3 true set# var ... 3 === '3' false setUTC# //Global variable declarations where # is one of Date, Day, FullYear, Hours, < 2<3 true function funcA([param1,param2,...]) 'a' < 'A' false Milliseconds, Minutes, Month, Seconds, Time, { TimezoneOffset var ... <= 2 <= 3 true toDateString – the date in English. //Local variable declarations – visible in nested functions > 2>3 false toGMTString – the date & time in English. >= 2>3 false toLocaleDateString – the date in the locale language. [function innerFuncA([iparam1,iparam2...]) toLocaleString – date & time in the locale language. { = i=2 i is assigned var ... the value 2 toLocaleTimeString – time in the locale language. //Variables local to innerFuncA toTimeString – time in English. += i+=1 3 //your code here toUTCString – date & time in UTC, English }] -= i-=1 2 valueOf – milliseconds since midnight 01 January 1970, i*= i*=3 6 UTC aName='ExplainThat!'; Math Object //implicit global variable creation /= i/=2 3 //your code here E, LN10, LN2, LOG10E, LOG2E, PI, SQRT1_2, SQRT2 %= i%=2 1 abs – absolute value } Nomenclature Rules i = 2;j = 5; #(n) - trigonometric functions Function and variable names can consist of any && (AND) (i <= 2) && (j < 7) true a#(n) - inverse trigonometric functions alphanumeric character. $ and _ are allowed. The first where # is one of cos, sin or tan character cannot be numeric. Many extended ASCII || (OR) (i%2 > 0) || (j%2 == 0) false ceil(n) – smallest whole number >= n characters are allowed. There is no practical limit on ! (NOT) (i==2) && !(j%2 == 0) true name length. Names are case-sensitive. exp(n) – returns en If two or more variables or functions or a variable & a i = 2;j = 7; floor(n) – biggest whole number <= n function are declared with the same name the last & (bitwise) i&j 2 log(n) – logarithm of n to the base e declaration obliterates all previous ones. Using a max(n1,n2) – bigger of n1 and n2 keyword as a variable or function name obliterates that | (bitwise) i|j 7 keyword. min(n1,n2) – smaller of n1 and n2 ^(XOR) i^j 5 Visibility & Scope pow(a,b) - ab Assignments without the use of the var keyword result << 2<<1 4 random – random number between 0 and 1 in a new global variable of that name being created. >> 2>>1 1 round(n) – n rounded down to closest integer Variables declared with the var keyword outwith the sqrt(n) – square root of n >>> i=10 (binary 1010) 23 body of a function are global. Variables declared with i>>>2 Number Object the var keyword inside the body of a function are local MAX_VALUE - ca 1.7977E+308 to that function. Local variables are visible to all nested Internal Functions functions. MIN_VALUE – ca 5E-324 decodeURI - reverses encodeURI Local entities hide globals bearing the same name. NEGATIVE_INFINITY, POSITIVE_INFINITY decodeURIComponent - reverses encodeURI... Variable Types n.toExponential(m) – n in scientific notation with m encodeURI – encodes everything except :/? decimal places. string: var s = 'explainthat' or “explainthat” &;,~@&=$+=_.*()# and alphanumerics. n.toFixed() - n rounded to the closest whole number. number: var n = 3.14159, 100, 0... encodeURIComponent – encodes everything except _.-!~*() and alphaumerics. n.toPrecision(m) – n rounded to m figures. boolean: var flag = false or true escape – hexadecimal string encoding. Does not Hexadecimal numbers are designated with the prefix object: var d = new Date(); 0x or 0X. e.g. 0xFF is the number 255. encode +@/_-.* and alphanumerics. function: var Greet = function sayHello() {alert('Hello')}unescape – reverses escape String Object JavaScript is a weakly typed language – i.e. a simple eval – evaluates JavaScript expressions length – number of characters in the string assignment is sufficient to change the variable type. The s.charAt(n) – returns s[n]. n starts at 0 typeof keyword can be used to check the current isNaN – true if the argument is not a number. variable type. isFinite – isFinite(2/0) returns false s.charCodeAt(n) – Unicode value of s[n] Special Values parseInt - parseInt(31.5°) returns 31 s.fromCharCode(n1,n2..) - string built from Unicode values n1, n2... The special values false, Infinity, NaN, null, true & parseFloat - parseFloat(31.5°) returns 31.5 undefined are recognized. null is an object. Infinity s1.indexOf(s2,n) – location of s2 in s1 starting at Array Object position n and NaN are numbers. length – number of elements in the array Operators s1.lastIndexOf(s2) – location of s2 in s1 starting from concat – concatenates argument, returns new array. the end Operator Example Result join – returns elements as a string separated by s.substr(n 1,n2) – returns substring starting from n1 upto + 3+2 5 argument (default is ,) character preceding n2. No n2 = extract till end. n1 < 0 = 'explain' + 'that' explainthat pop – suppress & return last element extract from end. - 3-2 -1 push – adds new elements to end of array & returns s.toLowerCase() - returns s in lower case characters new length. s.toUpperCase() - care to guess? * 3*2 6 reverse – inverts order of array elements shift – suppress & return first element
  • 2. JavaScript Quick Reference Card1.03 Escape Sequences { alert(num); ownerDocument – take a guess n - new line, r - carriage return, t – tab character, num--;} style – CSS style declaration - character, ' - apostrophe, '' - quote } tagName – element tag type. Curiously, always in uNNNN – Unicode character at NNNN uppercase e.g. u25BA gives the character ► function doLoop(num){ textContent – the Firefox equivalent of innerText JavaScript in HTML do{ location Object External JavaScript alert(num); host – URL of the site serving up the document num--; href – the entire URL to the document <script type=”text/javascript” defer=”defer” src=”/scripts/explainthat.js”></script> }while (num > 0); pathname – the path to the document on the host Inline JavaScript } protocol – the protocol used, e.g. http <script type=”text/javascript”> reload(p) - reload the document. From the cache if p is //your code here function forLoop(num){ true. </script> replace(url) – replace the current document with the var i; Comments one at url. Discard document entry in browser history. for (i=0;i<num;i++){ /* Comments spanning multiple lines */ screen Object alert(num); // Simple, single line, comment height – screen height in pixels } Conditional Execution width – screen width in pixels } if (Condition) CodeIfTrue;else CodeIfFalse4 window Object Multiline CodeIf# must be placed in braces, {} alert(msg) – displays a dialog with msg break causes immediate termination of the loop. switch (variable) clearInterval(id) – clears interval id set by setInterval loop statements after continue are skipped and the next { execution of the loop is performed. clearTimeout(id) – clears timeout id set by setTimeout case Value1:Code; confirm(msg) – shows a confirmation dialog break; function forInLoop(){ print() - prints the window contents case Value2:Code; var s,x; prompt(msg,[default]) – shows prompt dialog, break; optionally with default content. Returns content or null. for (x in document) ..... setInterval(expr,interval) – sets repeat at interval ms. { The function expr is evaluated5 . default:Code; s=x + ' = ' + document[x]; setTimeout(expr,time) Like setInterval but non- } alert(s); repeating. 5 variable can be boolean, number, string or even date. } Notes (condition)?(CodeIfTrue):(CodeIfFalse) } 1 Evaluates after use 2 Evaluates before use Parentheses are not necessary but advisable 3 Zero-fill right shift 4 Note the semicolon! This code is best tested in Opera which offers the option 5 Error Handling Passing arguments to function calls via expr is not well of stopping the script at each alert. In place of supported. Method 1:The onerror event document any JavaScript object or an array can be used to loop through its properties/elements. Color Coding <script type=”text/javascript”> return italics – user code blue – JavaScript Keywords function whenError(msg,url,lineNo){ //use parameters to provide meaningful messages return causes immediate termination of the JavaScript red – Option object – JavaScript DOM object function. If no value is returned, or if return is missing green – only numeric values blue - object properties } the function return type is undefined. green – object methods magenta – object events window.onerror = whenError document Object Tested with Internet Explorer 6+, Firefox 1.5+ & Opera </script> body - the body of the document 9.1+. Place this code in a separate <script>..</script> tag cookie - read/write the document cookies pair to trap errors occurring in other scripts. This technique blocks errors without taking corrective action. domain – where was the document served from? forms[] - array of all forms in the document images[] - array of all images in the document Method 2:The try..catch..finally statement referrer – who pointed to this document? function showLogValue(num){ URL – the URL for the document var s = 'No Error'; getElementById(id) – element bearing ID of id try getElementsByName(n) – array of elements named n {if (num < 0) throw 'badnum'; getElementsByTagName(t) - array of t tagged if (num == 0) throw 'zero'; } elements catch (err) write – write plain or HTML text to the document { s = err; onload – occurs when the document is loaded switch (err) { onunload – occurs when user browses away, tab is case 'badnum':num = -num; closed etc. break; Element Object case 'zero':num = 1; By element we mean any HTML element retrieved using break; } the document.getElementBy# methods. } attributes – all element attributes in an array [finally{ alert([s,Math.log(num)]);}] className – the CSS style assigned to the element } id – the id assigned to the element The finally block is optional. The two techniques can be innerHTML – HTML content of the element used in concert. innerText – content of the element shorn of all HTML Looping tags. Does not work in Firefox function whileLoop(num){ offset# – element dimensions (# = Height/Width) or while (num > 0) location(# = Left/Right) in pixels