Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to access variables in a different script file

// first.js...(first script file)
var colorCodes = {
  back  : "#fff",
  front : "#888",
  side  : "#369"
};

//in another file...(second script file)
alert(colorCodes.back); // alerts `#fff`

//in your html...
<script type="text/javascript" src="first.js"></script> 
<script type="text/javascript" src="second.js"></script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: add points to numbers js 
Javascript :: how to delete current clicked item in array react 
Javascript :: (node:3644) UnhandledPromiseRejectionWarning: TypeError [EMOJI_TYPE]: Emoji must be a string or GuildEmoji/ReactionEmoji 
Javascript :: convert days to weeks and days javascript typescript 
Javascript :: javascript append classname 
Javascript :: find 401 error and logout axios in react 
Javascript :: javascript append to object 
Javascript :: string to char code array javascript 
Javascript :: * ws in ./node_modules/puppeteer/lib/WebSocketTransport.js 
Javascript :: when click play sound 
Javascript :: Half or Right Triangle star pattern in JavaScript 
Javascript :: appregistry react native 
Javascript :: check if all array elements are equal 
Javascript :: Printer Print using HTML 
Javascript :: express ubuntu ERR_CONNECTION_REFUSED 
Javascript :: canvas rounded corners 
Javascript :: includes in javascript 
Javascript :: modal example react native 
Javascript :: IntersectionObserver polyfill 
Javascript :: js switch 
Javascript :: base64 js vanilla 
Javascript :: react form hook trigger is not a function 
Javascript :: how to navigate with navintems for react-bootstrap without refreshing the whole page 
Javascript :: javascript reduce return array 
Javascript :: javascript compare timestamp 
Javascript :: d3.js onclick event 
Javascript :: how to check if username already exists in database using javascript 
Javascript :: persistent bugger javascript code 
Javascript :: how to add a key in a react element 
Javascript :: of() angular 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =