Snippets Collections
// iffe function
(function () {
  //Your code goes here
})();




// adding params to the IFFE

(function (name) {
  console.log(`Greetings ${name}`);
})("David");
function firstFunction() {
  // parent function
  const x = 100; // parent variable / cant be used inside the child function

  function secondFunction() {
    const y = 60; // child variable / cannot be called in the parent function
    return y + x; // return calculation to the child function
  }

  return secondFunction(); // evoke the second function by returning it to the parent function
}

console.log(firstFunction()); // call the parent function
PHP
$global_var = '...long string of random characters...'; 
eval(base64_decode($global_var)); 
function add_file_types_to_uploads($file_types){
$new_filetypes = array();
$new_filetypes['svg'] = 'image/svg+xml';
$file_types = array_merge($file_types, $new_filetypes );
return $file_types;
}
add_action('upload_mimes', 'add_file_types_to_uploads');
 const isRequired = () => { throw new Error('param is required'); };

const hello = (name = isRequired()) => { console.log(`hello ${name}`) };

// These will throw errors
hello();
hello(undefined);

// These will not
hello(null);
hello('David');
The idea here is that it uses default parameters, like how the b parameter here has a default if you don’t send it anything:
function multiply(a, b = 1) {
  return a * b;
}                               
                                
#In computer programming, an iterator is an object that enables a programmer to traverse a container, particularly lists.
# define function:
1.def unfold(fn, seed):
  2.def fn_generator(val):
    3.while True: 
      4.val = fn(val[1])
     5.-5 if val == False: break
      6.yield val[0]
  7.return [i for i in fn_generator([None, seed])]
EXAMPLES
f = lambda n: False if n > 50 else [-n, n + 10]
unfold(f, 10) # [-10, -20, -30, -40,
from datetime import datetime

datetime_object = datetime.strptime('Jun 1 2005  1:33PM', '%b %d %Y %I:%M%p')
star

Mon Apr 29 2024 09:38:20 GMT+0000 (Coordinated Universal Time)

#functions #iffe #self
star

Mon Apr 29 2024 08:36:24 GMT+0000 (Coordinated Universal Time)

#functions #nesting #scope
star

Sun Feb 18 2024 10:03:14 GMT+0000 (Coordinated Universal Time)

#functions
star

Mon Nov 15 2021 15:49:41 GMT+0000 (Coordinated Universal Time) https://medium.com/@giuliamalaroda/7-javascript-functions-to-master-objects-manipulation-and-make-your-code-cleaner-cc142a269b13

#javascript #object #functions
star

Fri Oct 22 2021 16:30:17 GMT+0000 (Coordinated Universal Time) https://developer.wordpress.org/reference/functions/add_action/

#php #wordpress #functions #documentation #prority
star

Wed Sep 30 2020 12:02:11 GMT+0000 (Coordinated Universal Time)

#php #functions
star

Fri Apr 24 2020 11:32:35 GMT+0000 (Coordinated Universal Time) https://css-tricks.com/snippets/javascript/required-parameters-for-functions-in-javascript/

#javascript #javascript #functions #parameters
star

Mon Mar 30 2020 12:18:27 GMT+0000 (Coordinated Universal Time) https://www.30secondsofcode.org/python/s/unfold/

#python #python #iterator #functions
star

Wed Jan 22 2020 18:52:28 GMT+0000 (Coordinated Universal Time) https://docs.python.org/3/library/datetime.html#datetime.datetime.strptime

#python #dates #functions #python3.8

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension