B
B
Bogdan2017-05-04 16:25:36
JavaScript
Bogdan, 2017-05-04 16:25:36

Global CoffeeScript function?

Hello. I use global functions by declaring them through the window object, can I do something to use my own objects for each file with functions?

window.capitalize_Words = ( $str ) -> "#{ $str.charAt( 0 ).toUpperCase( ) }#{ $str.slice( 1 ) }"

If in a file with functions to insert a line
capitalize_Words = ( $str ) -> "#{ $str.charAt( 0 ).toUpperCase( ) }#{ $str.slice( 1 ) }"

root = exports ? this

then in other files when the function is run, it gives an error
root.capitalize_Words( 'Тест' )
Uncaught ReferenceError: root is not defined

Tell me how to work with global variables and functions? Thanks

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question