#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    7
    Rep Power
    0

    Newbie to javasctrip what is [?]


    i am new to java script ,so i am just starting

    can any explain to me this code

    code:
    window.clearRequestInterval = function(handle) {
    window.cancelAnimationFrame ? window.cancelAnimationFrame(handle.value) :
    window.webkitCancelAnimationFrame ? window.webkitCancelAnimationFrame(handle.value) :
    window.webkitCancelRequestAnimationFrame ? window.webkitCancelRequestAnimationFrame(handle.value) : /* Support for legacy API */
    window.mozCancelRequestAnimationFrame ? window.mozCancelRequestAnimationFrame(handle.value) :
    window.oCancelRequestAnimationFrame ? window.oCancelRequestAnimationFrame(handle.value) :
    window.msCancelRequestAnimationFrame ? window.msCancelRequestAnimationFrame(handle.value) :
    clearInterval(handle);


    what is the [?] this mean ? , i am looking for programmer group and a teacher to teach java script and html 5 , can any one help me
    i really need a teacher to ask , i already study on web and book. thank appreciate.^ ^
  2. #2
  3. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,009
    Rep Power
    2791
    That is the ternary/conditional operator; it is usually used as a short-hand for an if/else statement. You can find more information about it here.
    Javascript Code:
    condition ? true : false;
     
    if (condition) {
      true
    }
    else {
      false
    }

    Please read this information before making another thread.
    Last edited by Winters; February 18th, 2013 at 10:52 AM. Reason: typo
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    7
    Rep Power
    0
    Thank you i understand now ^ ^ , grateful.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    7
    Rep Power
    0

    and what is [!] mean ?


    and what is [!] mean?

    as i understand on action script 3.

    code:

    !whatever //if not = whatever


    isit same to java script , am i right?
  8. #5
  9. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,009
    Rep Power
    2791
    The exclamation mark is a logical not operator. As you say, it is the same in ActionScript. Javascript and ActionScript are both based on EMCAScript.

    You wrote "java script" as oppose to "javascript". Javascript is not Java or even related to it except in the loosest concept.

    You should read some good Javascript tutorials.

    Can anyone recommend some?
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  10. #6
  11. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    first of all, you (Tedeee) should get accustomed to using Google and looking up things yourself. If you don't know what "?" means, just search for "JavaScript question mark" -- and you'll get the result in less than a second. Or simply google for "JavaScript operators" or "JavaScript syntax" or whatever.

    I mean, it's not like JavaScript was some exotic language with only few people using it. You find information everywhere, all you need to do is open your Google and start typing search terms.

    The Mozilla developer network is a particular great resource. There are thousands of other tutorials, but many of them are hopelessly outdated and teach bad practices.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    7
    Rep Power
    0
    Yup thank for lending me, but i got the answer guys

    appreciate , nice to have friend to ask ^ ^
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    7
    Rep Power
    0

    one more question


    i already look in web but i am not sure if i understand right ?
    is about function

    code:
    (function(){
    whatever;
    )}();

    function(){
    whatever;
    }

    the top function will execute 1st ? rather that normal function ? what is the differences ,i already look on web still didt understand well , am i right? so the top function will execute 1st?
  16. #9
  17. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    In the first part, they create an anonymous function and immediately call it.

    The purpose of this is to avoid global variables. If you write "normal" code on the top level, each new variable will be global, that is, it's visible everywhere. This can lead to problems like accidentally overwriting existing variables etc.

    If, however, you declare variables inside a function, they are local, that is, they only exist for this particular function call.

    So this (function () {...})() pattern allows you to use "temporary variables" only visible to that particular piece of code:
    Code:
    // top level
    
    var x, y;
    x = 1;
    y = 2;
    alert(x + y);
    // x and y still exist afterwards, even though you don't need them
    
    (function () {
    	var x, y;
    	x = 1;
    	y = 2;
    	alert(x + y);
    })();
    // x and y don't exist here
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    7
    Rep Power
    0
    wonderful explanation , i understand very well ,but that if i type like this


    function(){
    var x, y;
    x = 1;
    y = 2;
    alert(x + y);
    }

    //will the x ,y wont be outside ? if it do not why i need to add () before i type function ? (function

    or that is a right way to type function ?
  20. #11
  21. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Your code does nothing. You define an anonymous function without storing it anywhere, so it's not accessible and will just be discarded.

    Check the MDN linked above on different ways of defining functions:

    https://developer.mozilla.org/en-US/...ning_functions

    When you append "()" to a function reference (possibly with arguments between the parentheses) you call that function. This is the same in pretty much any programming language.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  22. #12
  23. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,131
    Rep Power
    4304
    Originally Posted by Winters
    You should read some good Javascript tutorials.

    Can anyone recommend some?
    I think these are worth a look:
    Eloquent JavaScript: A Modern Introduction to Programming
    JavaScript Tutorial
    JavaScript Tutorial for Programmers
    Script Smarter: Quality JavaScript from Scratch
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    7
    Rep Power
    0
    thank guys , love you all !

IMN logo majestic logo threadwatch logo seochat tools logo