javascript pass string variable to function





As you probably already know, JavaScript allows you to create and assign functions to variables. This makes it possible to pass functions as parameters to other functions.We create two different variables a function type variable and a string type variable. function addPopupWindow(dateString) alert(dateString) but when i run it, a run time errow occurred. I am confused how to pass string variable to function.Note that I have used the alert dialog box of JavaScript. You dont even have to write a function in JavaScript for it. CleanCode NZ > Blog > Javascript > Pass PHP String To Javascript Variable .If there is any special characters like quote or new line, it is very likely javascript will be broken with an error message like:unterminated string literal. Hi When I pass a numerical variable to a JavaScript function, everything is OK but when I pass it a variable e.g. C123, IE shows a warning window with Error: C123 isSO when dress 9547, it works when dress Q123 it does not work even if I pass it as two variables and join them as strings. Passing a string variable to function. We can supply a variable to the function and use the same to process inside it .