0

This is a question for my personal knowledge.

Why does Javascript use " " for Strings (var myString = "test"), but for example when I try to call a function that has a string as a parameter I have to use ' ' ?

What is the difference between them ?

Mythul
  • 1,677
  • 6
  • 33
  • 52
  • 6
    There is no difference at all. Do you have an example of what you're trying to do? – James Allardice Jun 21 '13 at 08:01
  • 1
    They should be interchangeable. If you've something different please post it. –  Jun 21 '13 at 08:02
  • 1
    I'm sure you can call your function with " " instad of ' ' – Alexis Jun 21 '13 at 08:02
  • You can use either in JS. Sometimes different ones are used if e.g. the JS itself is part of an HTML string literal, so that the parent string literal is not closed in the middle. – UpTheCreek Jun 21 '13 at 08:02
  • 1
    As an informal standard, I tend to use double-quotes for user-visible strings and single quotes for programmatic strings. – RichieHindle Jun 21 '13 at 08:03

1 Answers1

1

Both can be used actually. So if you have a function:

function DoSomething(inputValue) {
    alert(inputValue);
}

You can call if in two ways:

DoSomething('test');

or

DoSomething("test");
Peter
  • 12,705
  • 10
  • 68
  • 105