Welcome!

Microservices Expo Authors: Dalibor Siroky, Elizabeth White, Pat Romanski, John Katrick, Liz McMillan

Related Topics: @DevOpsSummit, Microservices Expo, @ThingsExpo

@DevOpsSummit: Blog Feed Post

Node.js ABC’s - J is for JavaScript By @JoePruitt | @DevOpsSummit #IoT #API #DevOps #Microservices

JavaScript is primarily a client-based dynamic scripting language most commonly used within web browsers

Node.js is an open source runtime environment for server-side and network based applications.  At it's core, Node.js uses the Google V8 JavaScript engine to execute client code and a large portion of the core basic modules are written in JavaScript.  Since, for all practical purposes, writing Node.js applications is writing JavaScript applications, it makes sense to try to understand the gist of what JavaScript is.

What is JavaScript

JavaScript is primarily a client-based dynamic scripting language most commonly used within web browsers as client-side scripts to interact with the user, browser, and communicate asynchronously to servers.

If you have been part of any web-based development, odds are you have worked with JavaScript in one form or another.  In this article, I'll focus on the aspects of JavaScript that are relevant within the Node.js environment.

Types

js

Node.js has only a few core object types including boolean, number, object, and string.  There are three complex types consisting of the array, function, and object.  And, finally, null and undefined are special objects that are treated in their own way.
> typeof 10;
'number'
> typeof "HI";
'string'
> typeof function() { }
'function

Constants

While Node.js does support the const keyword, is it not widely used.  A standard practice is to use all upperscore characters when defining a constant.

> var HOURS_PER_DAY = 24;

Numbers

All numbers in JavaScript are 64-bit 754 double-precision floating-point numbers.  For numbers that can be expressed in 2&53 bits, their type behaves much like an integer in any other language.

> 100
100
> 1/3
0.3333333333333333

There are functions that can help you convert strings to numbers

> parseInt("12345")
12345
> parseFloat("1.2345")
1.2345
> parseInt("1.2345")
1

Booleans

The boolean type can have values of true or false.  false, 0, empty strings, NaN, null, and undefined all evaluate to false and all other values evaluate to true.

Strings

Strings are sequences of Unicode characters that can be wrapped in single or double quote characters. The string type has built-in properties such as "length" to give you access to attributes about the string

> var s = "hi there"
> s
'hi there'
> s.length
8

Objects

JavaScript resolves around objects and are something you will use in virtually any JavaScript-based coding effort.  They are extensible allowing you to add and remove properties and methods.  To create an Object, you can use the new keyword or use the preferred object literal syntax

> var o = new Object();
undefined
> var o = {};
undefined

One of the benefits of Object-Literal syntax is that you can specify the contents of an object at initialization time

> var person = {
  first_name: "Joe",
  last_name: "Pruitt"
};

You can also add a new property to an object like this

> person.weight = 180;
180
> person['weight'] = 180;
180
> user
{ first_name: 'Joe',
  last_name: 'Pruitt',
  weight: 180 }

To delete an object or property, you can use the keyword:

> delete user.weight
true
> user
{ first_name: 'Joe',
  last_name: 'Pruitt' }

Arrays

The array type is a special implementation of the object type.  To create arrays, you can use the traditional notation, or the array-literal syntax

> var a1 = new Array();
undefined
> a1
[]
> var a2 = [];
undefined
> a2
[]

To add an item to an array, you can do one of the following

> var a = []
undefined
> a.push("hi")
1
> a
[ 'hi' ]
> a[a.length] = "there";
'there'
> a
[ 'hi', 'there' ]

Functions

JavaScript is a functional programming language in that functions are fully typed objects and can be extended, manipulated, and used as data.

A simple function is defined with the function keyword

> function hi(name) {
  console.log("Hey " + name + "!");
}
> hi("Joe");
Hey Joe!

Parameters are declared in the parameter list after the function name.  If too few parameters are passed in, the missing ones will be undefined.  If too many parameters are passed in, then the extras are ignored.

You can create an anonymous function without a name by using the following syntax

> var hi = function(name) {
  console.log("Hey " + name + "!");
}
> hi("Joe");
Hey Joe!

It is recommended to use named functions whenever possible as debugging becomes more difficult without a named context in exception chains.

Special Global Objects

Node.js has a couple of global variables that can come in handy.

  • console - The console object contains the well known log function as well as warn, time, timeEnd, and assert.
  • global - Similar to how a browser's JavaScript model has the window object which is global in scope, Node.js has the special global object.  Anything attached to it is available anywhere in your node application.
  • process - The process global variable contains information and methods about the current's environment.

Summary

It's beyond the scope of this article to get into all of the aspects of the JavaScript programming language.  For more details into the concepts I've covered, as well as others in the language, check out the JavaScript reference on w3schools.com - http://www.w3schools.com/jsref/default.asp.

Read the original blog entry...

More Stories By Joe Pruitt

Joe Pruitt is a Principal Strategic Architect at F5 Networks working with Network and Software Architects to allow them to build network intelligence into their applications.

@MicroservicesExpo Stories
The nature of test environments is inherently temporary—you set up an environment, run through an automated test suite, and then tear down the environment. If you can reduce the cycle time for this process down to hours or minutes, then you may be able to cut your test environment budgets considerably. The impact of cloud adoption on test environments is a valuable advancement in both cost savings and agility. The on-demand model takes advantage of public cloud APIs requiring only payment for t...
"Codigm is based on the cloud and we are here to explore marketing opportunities in America. Our mission is to make an ecosystem of the SW environment that anyone can understand, learn, teach, and develop the SW on the cloud," explained Sung Tae Ryu, CEO of Codigm, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
High-velocity engineering teams are applying not only continuous delivery processes, but also lessons in experimentation from established leaders like Amazon, Netflix, and Facebook. These companies have made experimentation a foundation for their release processes, allowing them to try out major feature releases and redesigns within smaller groups before making them broadly available. In his session at 21st Cloud Expo, Brian Lucas, Senior Staff Engineer at Optimizely, discussed how by using ne...
Many enterprise and government IT organizations are realizing the benefits of cloud computing by extending IT delivery and management processes across private and public cloud services. But they are often challenged with balancing the need for centralized cloud governance without stifling user-driven innovation. This strategy requires an approach that fundamentally reshapes how IT is delivered today, shifting the focus from infrastructure to services aggregation, and mixing and matching the bes...
"CA has been doing a lot of things in the area of DevOps. Now we have a complete set of tool sets in order to enable customers to go all the way from planning to development to testing down to release into the operations," explained Aruna Ravichandran, Vice President of Global Marketing and Strategy at CA Technologies, in this SYS-CON.tv interview at DevOps Summit at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
While we understand Agile as a means to accelerate innovation, manage uncertainty and cope with ambiguity, many are inclined to think that it conflicts with the objectives of traditional engineering projects, such as building a highway, skyscraper or power plant. These are plan-driven and predictive projects that seek to avoid any uncertainty. This type of thinking, however, is short-sighted. Agile approaches are valuable in controlling uncertainty because they constrain the complexity that ste...
Cavirin Systems has just announced C2, a SaaS offering designed to bring continuous security assessment and remediation to hybrid environments, containers, and data centers. Cavirin C2 is deployed within Amazon Web Services (AWS) and features a flexible licensing model for easy scalability and clear pay-as-you-go pricing. Although native to AWS, it also supports assessment and remediation of virtual or container instances within Microsoft Azure, Google Cloud Platform (GCP), or on-premise. By dr...
"This all sounds great. But it's just not realistic." This is what a group of five senior IT executives told me during a workshop I held not long ago. We were working through an exercise on the organizational characteristics necessary to successfully execute a digital transformation, and the group was doing their ‘readout.' The executives loved everything we discussed and agreed that if such an environment existed, it would make transformation much easier. They just didn't believe it was reali...
It’s “time to move on from DevOps and continuous delivery.” This was the provocative title of a recent article in ZDNet, in which Kelsey Hightower, staff developer advocate at Google Cloud Platform, suggested that “software shops should have put these concepts into action years ago.” Reading articles like this or listening to talks at most DevOps conferences might make you think that we’re entering a post-DevOps world. But vast numbers of organizations still struggle to start and drive transfo...
Agile has finally jumped the technology shark, expanding outside the software world. Enterprises are now increasingly adopting Agile practices across their organizations in order to successfully navigate the disruptive waters that threaten to drown them. In our quest for establishing change as a core competency in our organizations, this business-centric notion of Agile is an essential component of Agile Digital Transformation. In the years since the publication of the Agile Manifesto, the conn...
"We're developing a software that is based on the cloud environment and we are providing those services to corporations and the general public," explained Seungmin Kim, CEO/CTO of SM Systems Inc., in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
The cloud revolution in enterprises has very clearly crossed the phase of proof-of-concepts into a truly mainstream adoption. One of most popular enterprise-wide initiatives currently going on are “cloud migration” programs of some kind or another. Finding business value for these programs is not hard to fathom – they include hyperelasticity in infrastructure consumption, subscription based models, and agility derived from rapid speed of deployment of applications. These factors will continue to...
While some developers care passionately about how data centers and clouds are architected, for most, it is only the end result that matters. To the majority of companies, technology exists to solve a business problem, and only delivers value when it is solving that problem. 2017 brings the mainstream adoption of containers for production workloads. In his session at 21st Cloud Expo, Ben McCormack, VP of Operations at Evernote, discussed how data centers of the future will be managed, how the p...
Enterprises are adopting Kubernetes to accelerate the development and the delivery of cloud-native applications. However, sharing a Kubernetes cluster between members of the same team can be challenging. And, sharing clusters across multiple teams is even harder. Kubernetes offers several constructs to help implement segmentation and isolation. However, these primitives can be complex to understand and apply. As a result, it’s becoming common for enterprises to end up with several clusters. Thi...
Let's do a visualization exercise. Imagine it's December 31, 2018, and you're ringing in the New Year with your friends and family. You think back on everything that you accomplished in the last year: your company's revenue is through the roof thanks to the success of your product, and you were promoted to Lead Developer. 2019 is poised to be an even bigger year for your company because you have the tools and insight to scale as quickly as demand requires. You're a happy human, and it's not just...
DevOps teams have more on their plate than ever. As infrastructure needs grow, so does the time required to ensure that everything's running smoothly. This makes automation crucial - especially in the server and network monitoring world. Server monitoring tools can save teams time by automating server management and providing real-time performance updates. As budgets reset for the New Year, there is no better time to implement a new server monitoring tool (or re-evaluate your current solution)....
We just came off of a review of a product that handles both containers and virtual machines in the same interface. Under the covers, implementation of containers defaults to LXC, though recently Docker support was added. When reading online, or searching for information, increasingly we see “Container Management” products listed as competitors to Docker, when in reality things like Rocket, LXC/LXD, and Virtualization are Dockers competitors. After doing some looking around, we have decided tha...
"Opsani helps the enterprise adopt containers, help them move their infrastructure into this modern world of DevOps, accelerate the delivery of new features into production, and really get them going on the container path," explained Ross Schibler, CEO of Opsani, and Peter Nickolov, CTO of Opsani, in this SYS-CON.tv interview at DevOps Summit at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
The benefits of automation are well documented; it increases productivity, cuts cost and minimizes errors. It eliminates repetitive manual tasks, freeing us up to be more innovative. By that logic, surely, we should automate everything possible, right? So, is attempting to automate everything a sensible - even feasible - goal? In a word: no. Consider this your short guide as to what to automate and what not to automate.
identify the sources of event storms and performance anomalies will require automated, real-time root-cause analysis. I think Enterprise Management Associates said it well: “The data and metrics collected at instrumentation points across the application ecosystem are essential to performance monitoring and root cause analysis. However, analytics capable of transforming data and metrics into an application-focused report or dashboards are what separates actual application monitoring from relat...