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

    Join Date
    Feb 2013
    Location
    Pabna, Bangladesh
    Posts
    19
    Rep Power
    0

    Some definitions of JavaScript


    Hi everybody!

    I am a new member of your community. I hope your suggestion will help me a lot. So, please see the following things and response:

    What is string?
    What is parameter?
    What is parentheses () ?


    name!=null && name!=""
    Here what is the meaning of null?
    Here what is the meaning of “”?

    Thank you.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    50
    Rep Power
    35
    Hi active-worker, welcome to DevShed

    From w3schools:

    Strings

    The String object is used to manipulate a stored piece of text.

    String objects are created with new String().

    Code:
    var txt = new String("string");
    
    // or more simply:
    
    var txt = "string";
    http://www.w3schools.com/jsref/jsref_obj_string.asp


    Parameters (or Arguments)

    When you call a function, you can pass along some values to it, these values are called arguments or parameters.

    These arguments can be used inside the function.

    You can send as many arguments as you like, separated by commas (,)
    Code:
    myFunction(argument1, argument2);
    Declare the argument, as variables, when you declare the function:
    Code:
    function myFunction(var1, var2)
    {
      // some code..
    }
    http://www.w3schools.com/js/js_functions.asp


    Null

    Null is used to represent a variable that has no value.

    http://stackoverflow.com/questions/5...-in-javascript

    For the expression:
    Code:
    name!=null && name!=""
    If it was part of the 'if' statement:
    Code:
    if ( name != null && name != "" )
    {
      // some code..
    }
    and 'name' is a string object then the first part of the expression is checking if 'name' is not equal to (!=) null and (&&) 'name' is not equal to (!=) an empty string ("").

    Comments on this post

    • Jacques1 disagrees : When will the madness end? http://w3fools.com/
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    No, for heaven's sake, no!

    Edge360, please stop linking to w3schools. That's the last place you gonna get correct answers, and your quotes prove that yet again.

    You do not create strings with new String("..."). That's utter nonsense. Strings in JavaScript are created implicitly with string literals:

    Code:
    var hallo = 'Hallo world';
    // or with double quotes:
    var hi = "Hi there";
    Just like you create numbers by simply writing them down.

    This new String() stuff creates a special string wrapper object, which is for very, very special purposes only. I've never seen it being used by anyone in real life -- except for the victims of w3schools.

    Arguments and parameters are not the same. A parameter is a variable you write down in the function signature:

    Code:
    function fun(parameter_1, parameter_2, parameter_3) {
    	alert(parameter_1 + ' ' + parameter_2 + ' ' + parameter_3);
    }
    An argument is a value (or reference) you pass to a function when calling it:

    Code:
    var 
    	argument_1 = 10
    	, argument_2 = 20
    	, argument_3 = 30
    ;
    fun(argument_1, argument_2, argument_3);
    The expression with null and the empty string also makes no sense -- though that's not the fault of w3schools.

    JavaScript is weakly typed, which means it doesn't strictly distinguish between different data types. For example, the number 0 and the empty string '' are considered to be "equal" according to the == operator.

    This means that many checks with == or != will not behave like you might expect. For example, name != null does not only exclude null, it also exludes undefined. And name != '' does not only exclude the empty string, it also exludes 0, 0.0, NaN, undefined and empty arrays.

    Is that what you want? Then the condition would be a pretty bad way of describing that. Or did you actually just want to exclude null and the empty string? In that case, you need to use the strict (in)equality operators === and !==:

    Code:
    name !== null && name !== ''
    If you're looking for good learning resources, check the Mozilla developer network:

    https://developer.mozilla.org/en-US/learn/javascript
    Last edited by Kravvitz; April 10th, 2013 at 02:34 PM. Reason: fixed the font tags
    The 6 worst sins of securityHow 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".
  6. #4
  7. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,009
    Rep Power
    2791
    Stop legitimising the spammers. It's like feeding a Mogwai after midnight.
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    50
    Rep Power
    35
    Whoops... you really do learn something new everyday
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Location
    Pabna, Bangladesh
    Posts
    19
    Rep Power
    0
    Thank you so much for your response.

    I am happy to say that your answers help me a lot.

    I hope you will help me in future again.

    Thank you again.

IMN logo majestic logo threadwatch logo seochat tools logo