About 435,000 results
Open links in new tab
  1. javascript - Set type for function parameters? - Stack Overflow

    Is there a way to let a javascript function know that a certain parameter is of a certain type? Being able to do something like this would be perfect: function myFunction(Date myDate, String mySt...

  2. Function parameter type in JavaScript - Stack Overflow

    Aug 18, 2021 · if you want to enforce an specific data type you need to explicitly write that /** * looks for an specific item of the list. * * @param {Array<string>} data Array to search from. * …

  3. Javascript, pass type as parameter in functions - Stack Overflow

    Feb 4, 2016 · By defining function you can create something like class. function Apple (type) { this.type = type; this.color = "red"; this.getInfo = getAppleInfo; } Then you can create new …

  4. JavaScript: can I somehow strong type function parameters?

    Jul 11, 2017 · When it is necessary to check the type of a variable in javascript, the typeof function can be used to determine a variable's type. However, it returns 'object' for arrays and …

  5. Annotate javascript function parameters? - Stack Overflow

    Jan 18, 2015 · @nnnnnn: I know that, but that doesn't imply the algorithm doesn't expect a certain type. Even in extremely dynamically typed languages like bash shell, one must make contracts …

  6. Checking the types of function arguments in Javascript

    Dec 18, 2012 · jQuery.type({}) this will return "object" (assosiative array) but jQuery.type([]) this will return "array" while native javascript typeof will return object in both cases. – Kashif …

  7. javascript - Is there a way to provide named parameters in a …

    In ES2015, parameter destructuring can be used to simulate named parameters. It would require the caller to pass an object, but you can avoid all of the checks inside the function if you also …

  8. Set a default parameter value for a JavaScript function

    From ES6/ES2015, default parameters are in the language specification. function read_file(file, delete_after = false) { // Code } just works. Reference: Default Parameters - MDN. Default …

  9. Passing an array as a function parameter in JavaScript

    May 18, 2010 · I'd like to call a function using an array as parameters: const x = ['p0', 'p1', 'p2']; call_me(x[0], x[1], x[2]); // I don't like it function call_me (param0, param1 ...

  10. Passing string parameter in JavaScript function - Stack Overflow

    Aug 12, 2015 · I was trying to pass a string to a JavaScript function. As it's mentioned here - Pass a string parameter in an onclick function I'm using this simple code- &lt;!DOCTYPE html&gt; …

Refresh