Skip to content

Instantly share code, notes, and snippets.

@rizkytegar
Last active May 18, 2023 02:41
Show Gist options
  • Save rizkytegar/a19fc318fd21bef7d2527cc7628e6dbe to your computer and use it in GitHub Desktop.
Save rizkytegar/a19fc318fd21bef7d2527cc7628e6dbe to your computer and use it in GitHub Desktop.

Return

const nama = 'iky';

const cetakNama = (nama) => `hi, nama saya ${nama}`;
console.log(cetakNama(nama));

const cetakNama2 = (nama) => {
  return (
     `hi, nama saya ${nama}`
  );
}

console.log(cetakNama2(nama));

Basic Module

index

const cetakNama2 = require('./module')

console.log(cetakNama2('ikii'))

module

function cetakNama2(nama){
    return `hello nama ${nama}`;
}

module.exports = cetakNama2;

Node.JS Module System

const fs = require('fs'); // core module
const cetakNama2 = require('./module') // local module
const moment = require('moment'); // npm - node_module

index

const modules = require('./module') // local module

console.log(modules.Name)

module

function cetakNama2(nama){
    return `hello nama ${nama}`;
}

const Name = 'name';

module.exports = {cetakNama2, Name};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment