Results: 1580
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
session_write_close
Sessions automatically end when the PHP script finishes executing but can be manually ended using the
session_write_close()
function
by Valeri Tandilashvili
2 years ago
0
PHP
0
parse_ini_file
The function
parse_ini_file()
returns the settings as an associative array from
ini
file
by Valeri Tandilashvili
2 years ago
0
PHP
functions
0
Event emitter raises the event called
messageLogged
const EventEmitter = require('events');
const emitter = new EventEmitter();

// Register a listener
emitter.on('messageLogged', function() {
  console.log('Listener called');
});

// Raise an event
emitter.emit('messageLogged');
by Valeri Tandilashvili
2 years ago
0
Node
Events
Node.js Tutorial for Beginners - 1 Hour
0
Event emitter raises the event called
messageLogged
and passes parameters
const EventEmitter = require('events');
const emitter = new EventEmitter();

// Register a listener
emitter.on('messageLogged', function(arg1, arg2) {
  console.log('Listener called', arg2, arg1);
});

// Raise an event
emitter.emit('messageLogged', 'arg-first', 'arg-second');
by Valeri Tandilashvili
2 years ago
0
Node
Events
Node.js Tutorial for Beginners - 1 Hour
0
Event emitter raises the event called
messageLogged
and passes the object as an argument
const EventEmitter = require('events');
const emitter = new EventEmitter();

// Register a listener
emitter.on('messageLogged', function(obj) {
  console.log('Listener called', obj);
});

// Raise an event & passes the object
emitter.emit('messageLogged', {key1: 'Value 1', key2: 'Value 2'});
by Valeri Tandilashvili
2 years ago
0
Node
Events
Node.js Tutorial for Beginners - 1 Hour
0
Content of the logger module
const EventEmitter = require('events');

class Logger extends EventEmitter {
  log(message) {
    
    // Log the message
    console.log(message);
    
    // Raise an event
    this.emit('messageLogged', { id: 1, url: 'http://' });
  }
}

module.exports = Logger;
Content of the index file
const Logger = require('./logger');
const logger = new Logger();

// Register a listener
logger.on('messageLogged', function(arg) {
  console.log('Listener called', arg);
});

logger.log('message');
by Valeri Tandilashvili
2 years ago
0
Node
Events
Node.js Tutorial for Beginners - 1 Hour
0
Step 1:
press ALT + D
Step 2:
type  CMD and pressed Enter
When pressing ALT + D , typing in CMD and pressed Enter when on This PC (and Quick Access) via File Explorer, it opens up the command prompt in the C:\WINDOWS\system32 directory
by Luka Tatarishvili
2 years ago
0
cmd
command line
0
Multiple return in a function
It can be useful to have multiple returns in a function declaration as long as only 1 return is expected to run. For example:
function invert(x) {
  if (x === 0) {
     return 'input was zero';
  } else {
    return 1 / x;
  }
}
The function will still work using an if statement instead of an if...else statement
function invert(x) {
  if (x === 0) {
     return 'input was zero';
  }
  return 1 / x;
}
by Valeri Tandilashvili
2 years ago
0
JavaScript
return
0
return false if any member is greater than 4
The following function will return false if any number in an array of numbers is greater than 4. Otherwise, the function will return true
function lessThanFive(numbers) {
  for (let number of numbers) {
    if (number > 4) {
      return false;
    }
  }
  return true;
}
by Valeri Tandilashvili
2 years ago
0
JavaScript
return
0
Declare a variable that will be use later to return
In many functions, it is useful to declare a variable for the function to later return. For example:
function calculateSum(numberArray) {
    let sum = 0;
    for (let num of numberArray) {
        sum += num;
    }
    return sum;
}
by Valeri Tandilashvili
2 years ago
0
JavaScript
return
0
Results: 1580