When you want a really advanced light engine where objects create shadows, you should look into WebGL and use a 3d engine.
But when you don't need accurate shading and only want objects to create cones of light which illuminate the canvas without respect to content, this is what you could do.
- Have two canvases, the normal scene and a second background canvas
- Draw your scene with normal illumination on the front canvas
- Fill the second canvas all black, and then draw the lights on them.
- Draw the lightmap to the game scene using globalCompositeOperation = "multiply"
Areas which are all black on the lightmap will also be black in the final output (dark). Areas which are pure white, will be drawn the way they were originally on the input bitmap (bright). Any shades in between will be in twilight. You can also use colors in your lightmap.
Here is a jsfiddle demo:
A word of warning, though: It doesn't work in Internet Explorer because MSIE doesn't support the multiply composite operation yet (even in Version 11). There are workarounds for that, but that's a different topic for a different questions.