Javascript
Overview
The davinci platform supports using Javascript for creating dynamic content.
- VSCode
- Javascript code can be wrttien and run in
Visual Studio. Once coded, it can be copied and run within the browser sa well.
(assuming you are not using any node js modules that are not available as a web library)
- Web Desktop and Page
- davinci provides a
web desktop
and
page editor
where you can code, debug and run Javascript.
Setting up Javascript in VSCODE
- Install Node.js
- download the node js installer from
node. Run the installer which will install node.js on your machine.
To verify the install, open a terminal and type:
node -v
- Initialize your Workspace
The node js platform has isolated environments built into it from the ground up.
(in contrast to python)
When you create a folder for a javascript environment, all you need is a package.json
file which specifies the Javascript configuration for any Javascript run from within that folder.
To initialize the workspace and create the package.json file,
open a terminal and run:
npm init -y
To install node packages to your workspace, open a terminal and run :
npm install package-name
Davinci Provided Utilities
The following are the utilities available for import.
Importing Davinci Utilties
The following code demonstrates importing two utilities from the davinci javascript library.
const { val, url } = require('./davinci/javascript.js');